From 17f7690789837932f337adeb921fe005cf15cea2 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Sat, 21 Mar 2026 22:30:05 +0100 Subject: [PATCH] Fix clippy lints --- gui/src/config.rs | 7 +++---- gui/src/lib.rs | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gui/src/config.rs b/gui/src/config.rs index 6441329..c133457 100644 --- a/gui/src/config.rs +++ b/gui/src/config.rs @@ -20,14 +20,13 @@ pub use fs::*; mod fs { use super::Config; use anyhow::{Context, Ok}; - use serde_json; - const CONFIG_FILE_NAME: &'static str = "config.json"; - const XDG_PREFIX: &'static str = "inköpslista"; + const CONFIG_FILE_NAME: &str = "config.json"; + const XDG_PREFIX: &str = "inköpslista"; pub fn save_config(address: String) -> Result<(), anyhow::Error> { let xdg_dirs = xdg::BaseDirectories::with_prefix(XDG_PREFIX); - let conf = Config { address: address }; + let conf = Config { address }; let conf = serde_json::to_string(&conf).context("unable to serialize config")?; let path = xdg_dirs diff --git a/gui/src/lib.rs b/gui/src/lib.rs index e8c0d87..29fc51d 100644 --- a/gui/src/lib.rs +++ b/gui/src/lib.rs @@ -80,7 +80,7 @@ fn refresh_list(conf: &Arc>, app_weak: &slint::Weak) { let _ = app_weak.upgrade_in_event_loop(|app| { let list: ModelRc = app.global::().get_list(); let list: &VecModel = list.as_any().downcast_ref().expect("list is a VecModel"); - update_slint_list(new_list, &list); + update_slint_list(new_list, list); }); }); } @@ -125,7 +125,7 @@ pub fn run() -> Result<(), anyhow::Error> { state.on_add_to_list(move |item| { if let Some(index) = list.iter().position(|item2| item2.name == item) { let mut item2 = list.row_data(index).unwrap(); - item2.amount = item2.amount + 1; + item2.amount += 1; let item3 = item2.clone(); list.set_row_data(index, item2); let conf = conf.clone(); @@ -229,7 +229,7 @@ pub fn run() -> Result<(), anyhow::Error> { state.on_inc_amount(move |item| { if let Some(index) = list.iter().position(|item2| item2.name == item) { let mut item2 = list.row_data(index).unwrap(); - item2.amount = item2.amount + 1; + item2.amount += 1; let item3 = item2.clone(); list.set_row_data(index, item2); let conf = conf.clone(); @@ -247,7 +247,6 @@ pub fn run() -> Result<(), anyhow::Error> { eprintln!("{err:?}"); } }); - return; } }); @@ -256,7 +255,7 @@ pub fn run() -> Result<(), anyhow::Error> { state.on_dec_amount(move |item| { if let Some(index) = list.iter().position(|item2| item2.name == item) { let mut item2 = list.row_data(index).unwrap(); - item2.amount = item2.amount - 1; + item2.amount -= 1; let item3 = item2.clone(); list.set_row_data(index, item2); let conf = conf.clone(); @@ -284,7 +283,6 @@ pub fn run() -> Result<(), anyhow::Error> { eprintln!("{err:?}"); } }); - return; } } });