diff options
author | Cyril Plisko <cyril.plisko@mountall.com> | 2017-12-11 20:34:28 +0200 |
---|---|---|
committer | Cyril Plisko <cyril.plisko@mountall.com> | 2017-12-11 20:34:28 +0200 |
commit | a7abe5aaa6b721aae36ee19fb3dff36215b6e6fb (patch) | |
tree | d20bb31d2cd1e16ff55831fe782dd5fc07b8dd7a | |
parent | 2cfe498664df2062bd20487fa50601cb5bc6361e (diff) |
Implement `Default` rather than derive it
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -78,7 +78,7 @@ use std::ffi::OsString; const DEFAULT_PAGER_ENV: &str = "PAGER"; /// Keeps track of the current pager state -#[derive(Debug, Default)] +#[derive(Debug)] pub struct Pager { pager: Option<OsString>, env: Option<String>, @@ -86,6 +86,17 @@ pub struct Pager { skip_on_notty: bool, } +impl Default for Pager { + fn default() -> Self { + Self { + pager: None, + env: None, + on: true, + skip_on_notty: false, + } + } +} + impl Pager { /// Creates new instance of `Pager` with default settings pub fn new() -> Self { @@ -99,8 +110,7 @@ impl Pager { Self { pager: pager, env: String::from(env).into(), - on: true, - skip_on_notty: false, + ..Default::default() } } @@ -113,9 +123,7 @@ impl Pager { pub fn with_pager(pager: &str) -> Self { Self { pager: OsString::from(pager).into(), - env: None, - on: true, - skip_on_notty: false, + ..Default::default() } } |