From 267b7e62a5f1c3f79662801b28fcd210d21ee046 Mon Sep 17 00:00:00 2001 From: "J. Gerhards" Date: Wed, 18 Mar 2026 17:17:04 +0100 Subject: [PATCH] appease clippy With the new rust versions we can chain if let statements, this commit makes the code use them. Also fixes an anonymous lifetime in the metadata function in the player dbus interface and uses char_indices() instead of chars().enumerate() when indexing the parse string in client/error.rs. --- build.rs | 10 +++++----- src/client/error.rs | 2 +- src/client/status.rs | 10 +++++----- src/dbus/player.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.rs b/build.rs index 91127b0..7e6aa9d 100644 --- a/build.rs +++ b/build.rs @@ -19,11 +19,11 @@ fn main() { if let Ok(head) = repo.head() { // add the ref that HEAD points to to rerun-if - if let Ok(pointer) = head.resolve() { - if let Some(name) = pointer.name() { - let path = repo.path().join(name); - println!("cargo::rerun-if-changed={}", path.display()); - } + if let Ok(pointer) = head.resolve() + && let Some(name) = pointer.name() + { + let path = repo.path().join(name); + println!("cargo::rerun-if-changed={}", path.display()); } // emit the git hash if not overriden diff --git a/src/client/error.rs b/src/client/error.rs index a9c8065..bff11e3 100644 --- a/src/client/error.rs +++ b/src/client/error.rs @@ -220,7 +220,7 @@ impl Error { let mut begin = 0; // ACK [error@command_listNum] {current_command} message_text - for (i, chr) in output.chars().enumerate() { + for (i, chr) in output.char_indices() { match state { FindACK => { let ack = "ACK"; diff --git a/src/client/status.rs b/src/client/status.rs index 681b80b..904fa83 100644 --- a/src/client/status.rs +++ b/src/client/status.rs @@ -114,11 +114,11 @@ impl Song { vec.push(c.cover_directory.join(&*self.uri)); // Music/Celeste/Resurrections.mp3 -> covers/Celeste - if let Some(p) = self.uri.parent() { - if p.parent().is_some() { - // p.parent() is none if p = "" - vec.push(c.cover_directory.join(p)); - } + if let Some(p) = self.uri.parent() + && p.parent().is_some() + { + // p.parent() is none if p = "" + vec.push(c.cover_directory.join(p)); } vec.push(c.music_directory.join(&*self.uri)); diff --git a/src/dbus/player.rs b/src/dbus/player.rs index 55017c2..f543788 100644 --- a/src/dbus/player.rs +++ b/src/dbus/player.rs @@ -225,7 +225,7 @@ impl PlayerInterface { } #[zbus(property)] - async fn metadata(&self) -> HashMap<&str, Value> { + async fn metadata(&self) -> HashMap<&str, Value<'_>> { let s = self.status.read().await; let c = config().read().await;