From 4741dff61b5bf6e8194c0668eeaafdeccea11cef Mon Sep 17 00:00:00 2001 From: Breadway Date: Thu, 6 Aug 2026 08:46:39 +0800 Subject: [PATCH] Fix clippy warnings: needless lifetime, sort_by_key, dead_code guard field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - find_block: elide the unnecessary 'a lifetime - scan_wifi: use sort_by_key(Reverse) instead of sort_by for the signal-descending sort - WatcherHandle: mark the RecommendedWatcher field as intentionally unread — it's held only to keep the watcher alive for the process lifetime, never accessed directly --- src/src/commands/breadbar.rs | 2 +- src/src/commands/network.rs | 2 +- src/src/commands/theme.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/src/commands/breadbar.rs b/src/src/commands/breadbar.rs index 51fdefa..8bdbecb 100644 --- a/src/src/commands/breadbar.rs +++ b/src/src/commands/breadbar.rs @@ -33,7 +33,7 @@ pub struct BreadbarStyle { pub notification_border_radius: u32, } -fn find_block<'a>(css: &'a str, selector: &str) -> Option<(usize, usize)> { +fn find_block(css: &str, selector: &str) -> Option<(usize, usize)> { let pat = format!(r"(?m)^\s*{}\s*\{{", regex::escape(selector)); let re = Regex::new(&pat).ok()?; let m = re.find(css)?; diff --git a/src/src/commands/network.rs b/src/src/commands/network.rs index cf0254f..80be783 100644 --- a/src/src/commands/network.rs +++ b/src/src/commands/network.rs @@ -89,7 +89,7 @@ pub async fn scan_wifi() -> Vec { by_ssid.entry(ssid.to_string()).and_modify(|existing| if net.signal > existing.signal { *existing = net.clone() }).or_insert(net); } let mut list: Vec<_> = by_ssid.into_values().collect(); - list.sort_by(|a, b| b.signal.cmp(&a.signal)); + list.sort_by_key(|n| std::cmp::Reverse(n.signal)); list } diff --git a/src/src/commands/theme.rs b/src/src/commands/theme.rs index cb290e6..d9dcc91 100644 --- a/src/src/commands/theme.rs +++ b/src/src/commands/theme.rs @@ -128,7 +128,7 @@ pub fn watch_and_emit(app: &AppHandle) { app.manage(WatcherHandle(watcher)); } -struct WatcherHandle(RecommendedWatcher); +struct WatcherHandle(#[allow(dead_code)] RecommendedWatcher); fn tracing_or_eprintln(msg: &str) { eprintln!("{msg}");