summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyril Plisko <cyril.plisko@mountall.com>2017-12-11 20:34:28 +0200
committerCyril Plisko <cyril.plisko@mountall.com>2017-12-11 20:34:28 +0200
commita7abe5aaa6b721aae36ee19fb3dff36215b6e6fb (patch)
treed20bb31d2cd1e16ff55831fe782dd5fc07b8dd7a
parent2cfe498664df2062bd20487fa50601cb5bc6361e (diff)
Implement `Default` rather than derive it
-rw-r--r--src/lib.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 87f0a71..9d28e3f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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()
}
}