From 4ab70123adbe46b30b4263372ce005ef4b9f6839 Mon Sep 17 00:00:00 2001 From: Asmir Avdicevic Date: Thu, 26 Jun 2025 22:40:52 +0200 Subject: [PATCH] chore: update clippy --- src/cli.rs | 4 ++-- src/cli/authors.rs | 10 +++++----- src/keys.rs | 8 ++++---- src/ranger.rs | 19 +++++-------------- src/sync.rs | 2 +- tests/client.rs | 2 +- tests/gc.rs | 2 +- 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index f806f4b..5bf2c8e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -591,7 +591,7 @@ impl DocCommands { } => { let doc = get_doc(docs, env, doc).await?; let ticket = doc.share(mode, addr_options).await?; - println!("{}", ticket); + println!("{ticket}"); } Self::Set { doc, @@ -604,7 +604,7 @@ impl DocCommands { let key = key.as_bytes().to_vec(); let value = value.as_bytes().to_vec(); let hash = doc.set_bytes(author, key, value).await?; - println!("{}", hash); + println!("{hash}"); } Self::Del { doc, diff --git a/src/cli/authors.rs b/src/cli/authors.rs index 6cfe04e..3f5d2b8 100644 --- a/src/cli/authors.rs +++ b/src/cli/authors.rs @@ -48,7 +48,7 @@ impl AuthorCommands { Self::List => { let mut stream = authors.list().await?; while let Some(author_id) = stream.try_next().await? { - println!("{}", author_id); + println!("{author_id}"); } } Self::Default { switch } => { @@ -56,7 +56,7 @@ impl AuthorCommands { bail!("The --switch flag is only supported within the Iroh console."); } let author_id = authors.default().await?; - println!("{}", author_id); + println!("{author_id}"); if switch { env.set_author(author_id)?; println!("Active author is now {}", fmt_short(author_id.as_bytes())); @@ -68,7 +68,7 @@ impl AuthorCommands { } let author_id = authors.create().await?; - println!("{}", author_id); + println!("{author_id}"); if switch { env.set_author(author_id)?; @@ -81,7 +81,7 @@ impl AuthorCommands { } Self::Export { author } => match authors.export(author).await? { Some(author) => { - println!("{}", author); + println!("{author}"); } None => { println!("No author found {}", fmt_short(author.as_bytes())); @@ -94,7 +94,7 @@ impl AuthorCommands { println!("Imported {}", fmt_short(id.as_bytes())); } Err(err) => { - eprintln!("Invalid author key: {}", err); + eprintln!("Invalid author key: {err}"); } }, } diff --git a/src/keys.rs b/src/keys.rs index 2f83015..fec7bed 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -195,7 +195,7 @@ impl fmt::Display for NamespaceId { impl fmt::Debug for NamespaceSecret { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Namespace({})", self) + write!(f, "Namespace({self})") } } @@ -213,19 +213,19 @@ impl fmt::Debug for AuthorId { impl fmt::Debug for Author { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Author({})", self) + write!(f, "Author({self})") } } impl fmt::Debug for NamespacePublicKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "NamespacePublicKey({})", self) + write!(f, "NamespacePublicKey({self})") } } impl fmt::Debug for AuthorPublicKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "AuthorPublicKey({})", self) + write!(f, "AuthorPublicKey({self})") } } diff --git a/src/ranger.rs b/src/ranger.rs index 3738511..0162794 100644 --- a/src/ranger.rs +++ b/src/ranger.rs @@ -1203,12 +1203,7 @@ mod tests { e.key() ); } - assert_eq!( - expected.len(), - self.alice.len().unwrap(), - "{}: (alice)", - ctx - ); + assert_eq!(expected.len(), self.alice.len().unwrap(), "{ctx}: (alice)"); } fn assert_bob_set(&mut self, ctx: &str, expected: &[(K, V)]) { @@ -1218,12 +1213,10 @@ mod tests { assert_eq!( self.bob.get(e.key()).unwrap().as_ref(), Some(e), - "{}: (bob) missing key {:?}", - ctx, - e + "{ctx}: (bob) missing key {e:?}" ); } - assert_eq!(expected.len(), self.bob.len().unwrap(), "{}: (bob)", ctx); + assert_eq!(expected.len(), self.bob.len().unwrap(), "{ctx}: (bob)"); } } @@ -1360,8 +1353,7 @@ mod tests { for (e, _) in values { assert!( alice_sent.insert(e.key(), e).is_none(), - "alice: duplicate {:?}", - e + "alice: duplicate {e:?}" ); } } @@ -1375,8 +1367,7 @@ mod tests { for (e, _) in values { assert!( bob_sent.insert(e.key(), e).is_none(), - "bob: duplicate {:?}", - e + "bob: duplicate {e:?}" ); } } diff --git a/src/sync.rs b/src/sync.rs index 382083a..cd881d3 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -2516,7 +2516,7 @@ mod tests { while let Some(msg) = next_to_bob.take() { assert!(rounds < 100, "too many rounds"); rounds += 1; - println!("round {}", rounds); + println!("round {rounds}"); if let Some(msg) = bob.sync_process_message(msg, alice_peer_id, &mut bob_state)? { next_to_bob = alice.sync_process_message(msg, bob_peer_id, &mut alice_state)? } diff --git a/tests/client.rs b/tests/client.rs index f932eeb..8c94ec6 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -211,7 +211,7 @@ async fn test_default_author_persist() -> TestResult<()> { drop(iroh); let iroh = Node::persistent(iroh_root).spawn().await; if let Err(cause) = iroh.as_ref() { - panic!("failed to start node: {:?}", cause); + panic!("failed to start node: {cause:?}"); } iroh?.shutdown().await?; } diff --git a/tests/gc.rs b/tests/gc.rs index aca7716..da6143d 100644 --- a/tests/gc.rs +++ b/tests/gc.rs @@ -74,7 +74,7 @@ async fn redb_doc_import_stress() -> Result<()> { let mut to_import = Vec::new(); for i in 0..100 { let data = create_test_data(16 * 1024 * 3 + 1); - let path = temp_path.join(format!("file{}", i)); + let path = temp_path.join(format!("file{i}")); tokio::fs::write(&path, &data).await?; let key = Bytes::from(format!("{}", path.display())); to_import.push((key, path, data));