From e63509a3a7673ea41b4c937089a1cf6d2362fed3 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sat, 22 Apr 2023 13:45:44 +0100 Subject: [PATCH] refactor: fix a few new clippy warnings --- src/clients/clipboard.rs | 7 +++---- src/main.rs | 8 ++++---- src/script.rs | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/clients/clipboard.rs b/src/clients/clipboard.rs index 9eac7b2..68bbe59 100644 --- a/src/clients/clipboard.rs +++ b/src/clients/clipboard.rs @@ -59,8 +59,8 @@ impl ClipboardClient { let iter = senders.iter(); for (tx, sender_cache_size) in iter { if cache_size == *sender_cache_size { - let mut cache = lock!(cache); - let removed_id = cache + // let mut cache = lock!(cache); + let removed_id = lock!(cache) .remove_ref_first() .expect("Clipboard cache unexpectedly empty"); try_send!(tx, ClipboardEvent::Remove(removed_id)); @@ -131,8 +131,7 @@ impl ClipboardClient { } pub fn remove(&self, id: usize) { - let mut cache = lock!(self.cache); - cache.remove(id); + lock!(self.cache).remove(id); let senders = lock!(self.senders); let iter = senders.iter(); diff --git a/src/main.rs b/src/main.rs index e6d41ca..5fadbec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,10 +60,10 @@ async fn main() -> Result<()> { |display| display, ); - let config_res = match env::var("IRONBAR_CONFIG") { - Ok(path) => ConfigLoader::load(path), - Err(_) => ConfigLoader::new("ironbar").find_and_load(), - }; + let config_res = env::var("IRONBAR_CONFIG").map_or_else( + |_| ConfigLoader::new("ironbar").find_and_load(), + ConfigLoader::load, + ); let config = match config_res { Ok(config) => config, diff --git a/src/script.rs b/src/script.rs index 328a927..9a4d43d 100644 --- a/src/script.rs +++ b/src/script.rs @@ -229,7 +229,7 @@ impl Script { let mut args_list = vec!["-c", &self.cmd]; if let Some(args) = args { - args_list.extend(args.iter().map(|s| s.as_str())); + args_list.extend(args.iter().map(String::as_str)); } debug!("Running sh with args: {args_list:?}"); @@ -322,7 +322,7 @@ impl Script { /// pub fn run_as_oneshot(&self, args: Option<&[String]>) { let script = self.clone(); - let args = args.map(|args| args.to_vec()); + let args = args.map(<[String]>::to_vec); spawn(async move { match script.get_output(args.as_deref()).await {