From a7abe5aaa6b721aae36ee19fb3dff36215b6e6fb Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Mon, 11 Dec 2017 20:34:28 +0200 Subject: Implement `Default` rather than derive it --- src/lib.rs | 20 ++++++++++++++------ 1 file 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, env: Option, @@ -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() } } -- cgit v1.2.3