From 4efe517d3e911f3e6e3682b5794cdc18052d53c3 Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Sat, 16 Nov 2024 09:13:22 -0800 Subject: [PATCH] fix: formatting in `tokio-util/` and `tokio/src/` --- tokio-util/src/time/wheel/mod.rs | 6 +----- tokio-util/tests/codecs.rs | 20 ++++---------------- tokio/src/loom/std/mod.rs | 8 ++------ tokio/src/runtime/time/wheel/mod.rs | 6 +----- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/tokio-util/src/time/wheel/mod.rs b/tokio-util/src/time/wheel/mod.rs index b2eaab587d7..c2c87a67627 100644 --- a/tokio-util/src/time/wheel/mod.rs +++ b/tokio-util/src/time/wheel/mod.rs @@ -280,11 +280,7 @@ mod test { #[test] fn test_level_for() { for pos in 0..64 { - assert_eq!( - 0, - level_for(0, pos), - "level_for({pos}) -- binary = {pos:b}" - ); + assert_eq!(0, level_for(0, pos), "level_for({pos}) -- binary = {pos:b}"); } for level in 1..5 { diff --git a/tokio-util/tests/codecs.rs b/tokio-util/tests/codecs.rs index bb3514cd249..1cfd9208e86 100644 --- a/tokio-util/tests/codecs.rs +++ b/tokio-util/tests/codecs.rs @@ -75,26 +75,17 @@ fn lines_decoder_max_length() { assert!(codec.decode(buf).is_err()); let line = codec.decode(buf).unwrap().unwrap(); - assert!( - line.len() <= MAX_LENGTH, - "{line:?}.len() <= {MAX_LENGTH:?}" - ); + assert!(line.len() <= MAX_LENGTH, "{line:?}.len() <= {MAX_LENGTH:?}"); assert_eq!("line 2", line); assert!(codec.decode(buf).is_err()); let line = codec.decode(buf).unwrap().unwrap(); - assert!( - line.len() <= MAX_LENGTH, - "{line:?}.len() <= {MAX_LENGTH:?}" - ); + assert!(line.len() <= MAX_LENGTH, "{line:?}.len() <= {MAX_LENGTH:?}"); assert_eq!("line 4", line); let line = codec.decode(buf).unwrap().unwrap(); - assert!( - line.len() <= MAX_LENGTH, - "{line:?}.len() <= {MAX_LENGTH:?}" - ); + assert!(line.len() <= MAX_LENGTH, "{line:?}.len() <= {MAX_LENGTH:?}"); assert_eq!("", line); assert_eq!(None, codec.decode(buf).unwrap()); @@ -103,10 +94,7 @@ fn lines_decoder_max_length() { assert_eq!(None, codec.decode(buf).unwrap()); let line = codec.decode_eof(buf).unwrap().unwrap(); - assert!( - line.len() <= MAX_LENGTH, - "{line:?}.len() <= {MAX_LENGTH:?}" - ); + assert!(line.len() <= MAX_LENGTH, "{line:?}.len() <= {MAX_LENGTH:?}"); assert_eq!("\rk", line); assert_eq!(None, codec.decode(buf).unwrap()); diff --git a/tokio/src/loom/std/mod.rs b/tokio/src/loom/std/mod.rs index b3a59d3d28d..14e552a9aa5 100644 --- a/tokio/src/loom/std/mod.rs +++ b/tokio/src/loom/std/mod.rs @@ -95,9 +95,7 @@ pub(crate) mod sys { match std::env::var(ENV_WORKER_THREADS) { Ok(s) => { let n = s.parse().unwrap_or_else(|e| { - panic!( - "\"{ENV_WORKER_THREADS}\" must be usize, error: {e}, value: {s}" - ) + panic!("\"{ENV_WORKER_THREADS}\" must be usize, error: {e}, value: {s}") }); assert!(n > 0, "\"{ENV_WORKER_THREADS}\" cannot be set to 0"); n @@ -106,9 +104,7 @@ pub(crate) mod sys { std::thread::available_parallelism().map_or(1, NonZeroUsize::get) } Err(std::env::VarError::NotUnicode(e)) => { - panic!( - "\"{ENV_WORKER_THREADS}\" must be valid unicode, error: {e:?}" - ) + panic!("\"{ENV_WORKER_THREADS}\" must be valid unicode, error: {e:?}") } } } diff --git a/tokio/src/runtime/time/wheel/mod.rs b/tokio/src/runtime/time/wheel/mod.rs index 431af1426e8..7040fc146b1 100644 --- a/tokio/src/runtime/time/wheel/mod.rs +++ b/tokio/src/runtime/time/wheel/mod.rs @@ -298,11 +298,7 @@ mod test { #[test] fn test_level_for() { for pos in 0..64 { - assert_eq!( - 0, - level_for(0, pos), - "level_for({pos}) -- binary = {pos:b}" - ); + assert_eq!(0, level_for(0, pos), "level_for({pos}) -- binary = {pos:b}"); } for level in 1..5 {