diff --git a/examples/example_fixture.rs b/examples/example_fixture.rs index 0b22817..218cb44 100644 --- a/examples/example_fixture.rs +++ b/examples/example_fixture.rs @@ -8,10 +8,10 @@ use std::process; fn run() -> Result<(), Box> { if let Ok(text) = env::var("stdout") { - println!("{}", text); + println!("{text}"); } if let Ok(text) = env::var("stderr") { - eprintln!("{}", text); + eprintln!("{text}"); } let code = env::var("exit") @@ -27,7 +27,7 @@ fn main() { let code = match run() { Ok(_) => 0, Err(ref e) => { - write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail"); 1 } }; diff --git a/src/assert.rs b/src/assert.rs index 6c2e9c4..77723c9 100644 --- a/src/assert.rs +++ b/src/assert.rs @@ -64,7 +64,7 @@ impl<'c> OutputAssertExt for &'c mut process::Command { panic!("Failed to spawn {:?}: {}", self, err); } }; - Assert::new(output).append_context("command", format!("{:?}", self)) + Assert::new(output).append_context("command", format!("{self:?}")) } } @@ -1084,13 +1084,13 @@ impl fmt::Display for AssertError { writeln!(f, "Command interrupted") } AssertReason::UnexpectedReturnCode { case_tree } => { - writeln!(f, "Unexpected return code, failed {}", case_tree) + writeln!(f, "Unexpected return code, failed {case_tree}") } AssertReason::UnexpectedStdout { case_tree } => { - writeln!(f, "Unexpected stdout, failed {}", case_tree) + writeln!(f, "Unexpected stdout, failed {case_tree}") } AssertReason::UnexpectedStderr { case_tree } => { - writeln!(f, "Unexpected stderr, failed {}", case_tree) + writeln!(f, "Unexpected stderr, failed {case_tree}") } }?; write!(f, "{}", self.assert) diff --git a/src/bin/bin_fixture.rs b/src/bin/bin_fixture.rs index 882819d..0c30c7d 100644 --- a/src/bin/bin_fixture.rs +++ b/src/bin/bin_fixture.rs @@ -8,10 +8,10 @@ use std::process; fn run() -> Result<(), Box> { if let Ok(text) = env::var("stdout") { - println!("{}", text); + println!("{text}"); } if let Ok(text) = env::var("stderr") { - eprintln!("{}", text); + eprintln!("{text}"); } if let Some(timeout) = env::var("sleep").ok().and_then(|s| s.parse().ok()) { @@ -31,7 +31,7 @@ fn main() { let code = match run() { Ok(_) => 0, Err(ref e) => { - write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail"); 1 } }; diff --git a/src/cargo.rs b/src/cargo.rs index 27da82e..2c1604d 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -181,7 +181,7 @@ impl Error for CargoError {} impl fmt::Display for CargoError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(ref cause) = self.cause { - writeln!(f, "Cause: {}", cause)?; + writeln!(f, "Cause: {cause}")?; } Ok(()) } @@ -222,7 +222,7 @@ pub fn cargo_bin>(name: S) -> path::PathBuf { } fn cargo_bin_str(name: &str) -> path::PathBuf { - let env_var = format!("CARGO_BIN_EXE_{}", name); + let env_var = format!("CARGO_BIN_EXE_{name}"); env::var_os(env_var) .map(|p| p.into()) .unwrap_or_else(|| target_dir().join(format!("{}{}", name, env::consts::EXE_SUFFIX))) diff --git a/src/cmd.rs b/src/cmd.rs index 654481c..22dcc3e 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -648,7 +648,7 @@ impl<'c> OutputAssertExt for &'c mut Command { let output = match self.output() { Ok(output) => output, Err(err) => { - panic!("Failed to spawn {:?}: {}", self, err); + panic!("Failed to spawn {self:?}: {err}"); } }; let assert = Assert::new(output).append_context("command", format!("{:?}", self.cmd)); diff --git a/src/output.rs b/src/output.rs index e072f19..8969b28 100644 --- a/src/output.rs +++ b/src/output.rs @@ -109,7 +109,7 @@ impl<'c> OutputOkExt for &'c mut process::Command { if output.status.success() { Ok(output) } else { - let error = OutputError::new(output).set_cmd(format!("{:?}", self)); + let error = OutputError::new(output).set_cmd(format!("{self:?}")); Err(error) } } @@ -266,8 +266,8 @@ enum OutputCause { impl fmt::Display for OutputCause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - OutputCause::Expected(ref e) => write!(f, "{:#}", e), - OutputCause::Unexpected(ref e) => write!(f, "{:#}", e), + OutputCause::Expected(ref e) => write!(f, "{e:#}"), + OutputCause::Unexpected(ref e) => write!(f, "{e:#}"), } } } @@ -369,9 +369,9 @@ fn format_bytes(data: &[u8], f: &mut impl fmt::Write) -> fmt::Result { .as_bstr() .lines_with_terminator() .skip(LINES_MAX_START + lines_omitted); - writeln!(f, "<{} lines total>", lines_total)?; + writeln!(f, "<{lines_total} lines total>")?; write_debug_bstrs(f, true, start_lines)?; - writeln!(f, "<{} lines omitted>", lines_omitted)?; + writeln!(f, "<{lines_omitted} lines omitted>")?; write_debug_bstrs(f, true, end_lines) } else if BYTES_MIN_OVERFLOW <= data.len() { write!( @@ -434,7 +434,7 @@ mod test { fn format_bytes() { let mut s = String::new(); for i in 0..80 { - s.push_str(&format!("{}\n", i)); + s.push_str(&format!("{i}\n")); } let mut buf = String::new(); diff --git a/tests/cargo.rs b/tests/cargo.rs index 5f074a5..b7a244a 100644 --- a/tests/cargo.rs +++ b/tests/cargo.rs @@ -34,7 +34,7 @@ fn mod_example() { .unwrap(); let mut cmd = bin_under_test.command(); let output = cmd.unwrap(); - println!("{:?}", output); + println!("{output:?}"); } } @@ -43,7 +43,7 @@ fn mod_example() { fn trait_example() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); let output = cmd.unwrap(); - println!("{:?}", output); + println!("{output:?}"); } #[test] @@ -51,12 +51,12 @@ fn trait_example() { fn cargo_bin_example_1() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); let output = cmd.unwrap(); - println!("{:?}", output); + println!("{output:?}"); } #[test] fn cargo_bin_example_2() { let mut cmd = Command::cargo_bin("bin_fixture").unwrap(); let output = cmd.unwrap(); - println!("{:?}", output); + println!("{output:?}"); }