From c7329b4dd3a36a4c5f5bc596f348adac132cde36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zongo=20T=C3=A9gawend=C3=A9=20Achille=20Caleb?= <104392821+Aquilesorei@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:55:03 +0000 Subject: [PATCH] removed duplicate code in save_config on main.rs --- src/main.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4839b02..bafe9eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,13 +111,10 @@ fn main() -> Result<(), Box> { let (config_handler, config) = match cosmic_config::Config::new(App::APP_ID, CONFIG_VERSION) { Ok(config_handler) => { - let config = match Config::get_entry(&config_handler) { - Ok(ok) => ok, - Err((errs, config)) => { - log::info!("errors loading config: {:?}", errs); - config - } - }; + let config = Config::get_entry(&config_handler).unwrap_or_else(|(errs, config)| { + log::info!("errors loading config: {:?}", errs); + config + }); (Some(config_handler), config) } Err(err) => { @@ -445,11 +442,6 @@ impl App { } fn save_config(&mut self) -> Command { - if let Some(ref config_handler) = self.config_handler { - if let Err(err) = self.config.write_entry(config_handler) { - log::error!("failed to save config: {}", err); - } - } if let Some(ref config_handler) = self.config_handler { if let Err(err) = self.config.write_entry(config_handler) {