From acd45e75f68ef3de53defcfb698481813ba13c9d Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 18 Oct 2020 22:50:22 +0800 Subject: [PATCH] feat: add is_show_debug_output --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 309ddea..ca75ffb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,12 @@ struct KeepRunningConfig { items: Vec, } +impl KeepRunningConfig { + fn is_show_debug_output(&self) -> bool { + self.show_debug_output.unwrap_or(false) + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] struct KeepRunningConfigItem { title: String, @@ -96,7 +102,7 @@ fn parse_keep_running_config() -> Option { }, }; - if keep_running_config.show_debug_output.unwrap_or(false) { + if keep_running_config.is_show_debug_output() { if let Ok(json) = serde_json::to_string_pretty(&keep_running_config) { debug!("Config: {}", json); } @@ -137,7 +143,7 @@ fn keep_runningd(keep_running_config: Arc) { }, _ => ( /* IGNORE */ ), } - } else if keep_running_config.show_debug_output.unwrap_or(false) { + } else if keep_running_config.is_show_debug_output() { debug!("Find: {:?}", &check_lines); } }