diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-02-11 14:33:17 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-02-11 14:33:17 +0200 |
commit | 78325817028096ca134b7c2bbd3bc6ca000a8f3e (patch) | |
tree | b373d1d9d781f16825bc91748978b5b49ac36879 | |
parent | b6df0fa5b7046bad97f63dc928a9776cecaee623 (diff) | |
download | subplot-78325817028096ca134b7c2bbd3bc6ca000a8f3e.tar.gz |
chore: use variables in Rust format strings
Change this:
format!("{}", foo)
into this:
format!("{foo}")
Support for this feature was added in Rust 1.58 (see
https://github.com/rust-lang/rust/releases/tag/1.58.0) and in 1.67
clippy suggests about this. Because the new style seems to be where
the Rust ecosystem is going, I think Subplot should follow to avoid
being needlessly different from most other projects.
Sponsored-by: author
-rw-r--r-- | build.rs | 12 | ||||
-rw-r--r-- | examples/seq/seq-extras.rs | 6 | ||||
-rw-r--r-- | src/bin/cli/mod.rs | 6 | ||||
-rw-r--r-- | src/bin/subplot.rs | 2 | ||||
-rw-r--r-- | src/bindings.rs | 10 | ||||
-rw-r--r-- | src/md/typeset.rs | 16 | ||||
-rw-r--r-- | src/md/visitor/embedded.rs | 2 | ||||
-rw-r--r-- | src/steps.rs | 2 | ||||
-rw-r--r-- | subplotlib-derive/src/lib.rs | 8 | ||||
-rw-r--r-- | subplotlib/helpers/subplotlib_impl.rs | 2 | ||||
-rw-r--r-- | subplotlib/src/scenario.rs | 4 | ||||
-rw-r--r-- | subplotlib/src/step.rs | 6 | ||||
-rw-r--r-- | subplotlib/src/steplibrary/datadir.rs | 3 | ||||
-rw-r--r-- | subplotlib/src/steplibrary/files.rs | 2 | ||||
-rw-r--r-- | subplotlib/src/steplibrary/runcmd.rs | 26 | ||||
-rw-r--r-- | subplotlib/subplot-rust-support.rs | 35 | ||||
-rw-r--r-- | tests/bindings-ubm.rs | 4 |
17 files changed, 61 insertions, 85 deletions
@@ -127,15 +127,11 @@ fn write_out_resource_file<'a>(paths: impl Iterator<Item = &'a Path>) -> Result< /// to contain `BUILTIN_{var}` to either the env value, or `{def}` if not /// provided. fn adopt_env_var(var: &str, def: &str) { - println!("cargo:rerun-if-env-changed=SUBPLOT_{var}", var = var); - if let Ok(value) = std::env::var(format!("SUBPLOT_{var}", var = var)) { - println!( - "cargo:rustc-env=BUILTIN_{var}={value}", - var = var, - value = value - ); + println!("cargo:rerun-if-env-changed=SUBPLOT_{var}"); + if let Ok(value) = std::env::var(format!("SUBPLOT_{var}")) { + println!("cargo:rustc-env=BUILTIN_{var}={value}",); } else { - println!("cargo:rustc-env=BUILTIN_{var}={def}", var = var, def = def); + println!("cargo:rustc-env=BUILTIN_{var}={def}"); } } diff --git a/examples/seq/seq-extras.rs b/examples/seq/seq-extras.rs index 79863fc..b2185fb 100644 --- a/examples/seq/seq-extras.rs +++ b/examples/seq/seq-extras.rs @@ -26,8 +26,7 @@ fn count_lines_in_stdout(context: &Runcmd, count: usize) { // step error. This will be reported as the reason the // scenario fails. throw!(format!( - "Incorrect number of lines, got {} expected {}", - stdout_count, count + "Incorrect number of lines, got {stdout_count} expected {count}", )); } } @@ -57,8 +56,7 @@ fn stderr_contains_two_things(context: &ScenarioContext, what: &str, other: &str if !stderr_has_both { throw!(format!( - "Stderr does not contain both of {:?} and {:?}", - what, other + "Stderr does not contain both of {what:?} and {other:?}", )) } } diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index 4e15efb..dacf9b6 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -97,7 +97,7 @@ impl TryFrom<&mut Document> for Metadata { impl Metadata { fn write_list(v: &[String], prefix: &str) { - v.iter().for_each(|entry| println!("{}: {}", prefix, entry)) + v.iter().for_each(|entry| println!("{prefix}: {entry}")) } pub fn write_out(&self) { @@ -107,7 +107,7 @@ impl Metadata { let templates: Vec<String> = self.impls.keys().map(String::from).collect(); Self::write_list(&templates, "templates"); for (template, filenames) in self.impls.iter() { - Self::write_list(filenames, &format!("functions[{}]", template)); + Self::write_list(filenames, &format!("functions[{template}]")); } Self::write_list(&self.bibliographies, "bibliography"); Self::write_list(&self.files, "file"); @@ -139,7 +139,7 @@ impl FromStr for OutputFormat { match s.to_ascii_lowercase().as_ref() { "plain" => Ok(OutputFormat::Plain), "json" => Ok(OutputFormat::Json), - _ => Err(format!("Unknown output format: `{}`", s)), + _ => Err(format!("Unknown output format: `{s}`")), } } } diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs index b86c613..7f51b5c 100644 --- a/src/bin/subplot.rs +++ b/src/bin/subplot.rs @@ -88,7 +88,7 @@ fn long_version() -> Result<String> { writeln!(ret, "{}", render_testament!(VERSION))?; writeln!(ret, "Crate version: {}", env!("CARGO_PKG_VERSION"))?; if let Some(branch) = VERSION.branch_name { - writeln!(ret, "Built from branch: {}", branch)?; + writeln!(ret, "Built from branch: {branch}")?; } else { writeln!(ret, "Branch information is missing.")?; } diff --git a/src/bindings.rs b/src/bindings.rs index 98379c9..2738aa1 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -176,7 +176,7 @@ impl Binding { case_sensitive: bool, mut types: HashMap<String, CaptureType>, ) -> Result<Binding, SubplotError> { - let regex = RegexBuilder::new(&format!("^{}$", pattern)) + let regex = RegexBuilder::new(&format!("^{pattern}$")) .case_insensitive(!case_sensitive) .build() .map_err(|err| SubplotError::Regex(pattern.to_string(), err))?; @@ -541,12 +541,12 @@ fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding, SubplotError> { let then: i32 = parsed.then.is_some().into(); if given + when + then == 0 { - let msg = format!("{:?}", parsed); + let msg = format!("{parsed:?}"); return Err(SubplotError::BindingWithoutKnownKeyword(msg)); } if given + when + then > 1 { - let msg = format!("{:?}", parsed); + let msg = format!("{parsed:?}"); return Err(SubplotError::BindingHasManyKeywords(msg)); } @@ -557,7 +557,7 @@ fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding, SubplotError> { } else if parsed.then.is_some() { (StepKind::Then, parsed.then.as_ref().unwrap()) } else { - let msg = format!("{:?}", parsed); + let msg = format!("{parsed:?}"); return Err(SubplotError::BindingWithoutKnownKeyword(msg)); }; @@ -641,7 +641,7 @@ mod test_bindings { "; let mut bindings = Bindings::new(); bindings.add_from_yaml(yaml).unwrap(); - println!("test: {:?}", bindings); + println!("test: {bindings:?}"); assert!(bindings.has(StepKind::Given, "I am Tomjon")); assert!(bindings.has(StepKind::When, "I declare myself king")); assert!(bindings.has(StepKind::Then, "there is applause")); diff --git a/src/md/typeset.rs b/src/md/typeset.rs index f63206a..aa6528d 100644 --- a/src/md/typeset.rs +++ b/src/md/typeset.rs @@ -14,7 +14,7 @@ use pandoc_ast::Target; /// Typeset an error as a Pandoc AST Block element. pub fn error(err: SubplotError) -> Block { - let msg = format!("ERROR: {}", err); + let msg = format!("ERROR: {err}"); Block::Para(error_msg(&msg)) } @@ -82,7 +82,7 @@ fn step( let step = ScenarioStep::new_from_str(text, prevkind); if step.is_err() { return ( - error_msg(&format!("Could not parse step: {}", text)), + error_msg(&format!("Could not parse step: {text}")), prevkind, ); } @@ -91,9 +91,9 @@ fn step( let m = match bindings.find("", &step) { Ok(m) => m, Err(e) => { - let w = Warning::UnknownBinding(format!("{}", e)); + let w = Warning::UnknownBinding(format!("{e}")); warnings.push(w.clone()); - return (error_msg(&format!("{}", w)), prevkind); + return (error_msg(&format!("{w}")), prevkind); } }; @@ -163,7 +163,7 @@ pub fn pikchr_to_block(pikchr: &str, class: Option<&str>, warnings: &mut Warning match PikchrMarkup::new(pikchr, class).as_svg() { Ok(svg) => typeset_svg(svg), Err(err) => { - warnings.push(Warning::Pikchr(format!("{}", err))); + warnings.push(Warning::Pikchr(format!("{err}"))); error(err) } } @@ -176,7 +176,7 @@ pub fn dot_to_block(dot: &str, warnings: &mut Warnings) -> Block { match DotMarkup::new(dot).as_svg() { Ok(svg) => typeset_svg(svg), Err(err) => { - warnings.push(Warning::Dot(format!("{}", err))); + warnings.push(Warning::Dot(format!("{err}"))); error(err) } } @@ -189,7 +189,7 @@ pub fn plantuml_to_block(markup: &str, warnings: &mut Warnings) -> Block { match PlantumlMarkup::new(markup).as_svg() { Ok(svg) => typeset_svg(svg), Err(err) => { - warnings.push(Warning::Plantuml(format!("{}", err))); + warnings.push(Warning::Plantuml(format!("{err}"))); error(err) } } @@ -225,5 +225,5 @@ fn typeset_svg(svg: Svg) -> Block { // referencing external files. fn svg_as_data_url(svg: Svg) -> String { let svg = base64::encode(svg.data()); - format!("data:image/svg+xml;base64,{}", svg) + format!("data:image/svg+xml;base64,{svg}") } diff --git a/src/md/visitor/embedded.rs b/src/md/visitor/embedded.rs index 840d9ed..68a4118 100644 --- a/src/md/visitor/embedded.rs +++ b/src/md/visitor/embedded.rs @@ -19,7 +19,7 @@ impl MutVisitor for EmbeddedFiles { _ => unreachable!(), }; let contents = if add_newline { - format!("{}\n", contents) + format!("{contents}\n") } else { contents.clone() }; diff --git a/src/steps.rs b/src/steps.rs index ccbc588..b0a15e9 100644 --- a/src/steps.rs +++ b/src/steps.rs @@ -109,7 +109,7 @@ impl fmt::Display for StepKind { StepKind::When => "when", StepKind::Then => "then", }; - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/subplotlib-derive/src/lib.rs b/subplotlib-derive/src/lib.rs index 7aef0dc..584d730 100644 --- a/subplotlib-derive/src/lib.rs +++ b/subplotlib-derive/src/lib.rs @@ -403,10 +403,7 @@ fn process_step(mut input: ItemFn) -> proc_macro2::TokenStream { for context in outer_ctx.into_iter().chain(contexts.iter()) { write!(contextattrs, "\n #[context({:?})]", ty_as_path(context)?).unwrap(); } - let func_args: Vec<_> = fields - .iter() - .map(|(ident, _)| format!("{}", ident)) - .collect(); + let func_args: Vec<_> = fields.iter().map(|(ident, _)| format!("{ident}")).collect(); let func_args = func_args.join(", "); format!( r#" @@ -424,9 +421,6 @@ fn process_step(mut input: ItemFn) -> proc_macro2::TokenStream { }} ``` "#, - stepname = stepname, - contextattrs = contextattrs, - func_args = func_args, ) }; let ret = quote! { diff --git a/subplotlib/helpers/subplotlib_impl.rs b/subplotlib/helpers/subplotlib_impl.rs index fac54ab..768337a 100644 --- a/subplotlib/helpers/subplotlib_impl.rs +++ b/subplotlib/helpers/subplotlib_impl.rs @@ -36,7 +36,7 @@ fn remember_target(context: &mut Context, somename: &str) { if let Some(file) = context.files.get(somename) { context.this_file = Some(file.clone()); } else { - throw!(format!("Unknown file {}", somename)); + throw!(format!("Unknown file {somename}")); } } diff --git a/subplotlib/src/scenario.rs b/subplotlib/src/scenario.rs index 7a78ae5..8c734b9 100644 --- a/subplotlib/src/scenario.rs +++ b/subplotlib/src/scenario.rs @@ -174,9 +174,9 @@ impl DebuggedContext { C: Debug, { let body = if alternate { - format!("{:#?}", obj) + format!("{obj:#?}") } else { - format!("{:?}", obj) + format!("{obj:?}") }; self.body.push(body); } diff --git a/subplotlib/src/step.rs b/subplotlib/src/step.rs index 7a70e23..12b4ddf 100644 --- a/subplotlib/src/step.rs +++ b/subplotlib/src/step.rs @@ -57,11 +57,11 @@ impl ScenarioStep { /// a formatted string then we won't be able to render it sadly. fn render_panic(name: &str, err: Box<dyn Any + Send>) -> String { if let Some(msg) = err.downcast_ref::<&str>() { - format!("step {} panic'd: {}", name, msg) + format!("step {name} panic'd: {msg}") } else if let Some(msg) = err.downcast_ref::<String>() { - format!("step {} panic'd: {}", name, msg) + format!("step {name} panic'd: {msg}") } else { - format!("step {} panic'd", name) + format!("step {name} panic'd") } } diff --git a/subplotlib/src/steplibrary/datadir.rs b/subplotlib/src/steplibrary/datadir.rs index 5a344df..5060f63 100644 --- a/subplotlib/src/steplibrary/datadir.rs +++ b/subplotlib/src/steplibrary/datadir.rs @@ -150,8 +150,7 @@ pub fn datadir_has_enough_space(datadir: &Datadir, bytes: u64) { let available = fs2::available_space(datadir.base_path())?; if available < bytes { throw!(format!( - "Available space check failed, wanted {} bytes, but only {} were available", - bytes, available + "Available space check failed, wanted {bytes} bytes, but only {available} were available", )); } } diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs index 8abe546..c60358f 100644 --- a/subplotlib/src/steplibrary/files.rs +++ b/subplotlib/src/steplibrary/files.rs @@ -90,7 +90,7 @@ pub fn touch_with_timestamp(context: &Datadir, filename: &Path, mtime: &str) { let fd = format_description!( "[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour]:[offset_minute]" ); - let full_time = format!("{} +00:00", mtime); + let full_time = format!("{mtime} +00:00"); let ts = OffsetDateTime::parse(&full_time, &fd)?; let (secs, nanos) = (ts.unix_timestamp(), 0); let mtime = FileTime::from_unix_time(secs, nanos); diff --git a/subplotlib/src/steplibrary/runcmd.rs b/subplotlib/src/steplibrary/runcmd.rs index 6692441..99605a3 100644 --- a/subplotlib/src/steplibrary/runcmd.rs +++ b/subplotlib/src/steplibrary/runcmd.rs @@ -353,7 +353,7 @@ pub fn exit_code_is(context: &Runcmd, exit: i32) { #[step] pub fn exit_code_is_not(context: &Runcmd, exit: i32) { if context.exitcode.is_none() || context.exitcode == Some(exit) { - throw!(format!("Expected exit code to not equal {}", exit)); + throw!(format!("Expected exit code to not equal {exit}")); } } @@ -422,7 +422,7 @@ fn check_matches(runcmd: &Runcmd, which: Stream, how: MatchKind, against: &str) #[step] pub fn stdout_is(runcmd: &Runcmd, text: &str) { if !check_matches(runcmd, Stream::Stdout, MatchKind::Exact, text)? { - throw!(format!("stdout is not {:?}", text)); + throw!(format!("stdout is not {text:?}")); } } @@ -435,7 +435,7 @@ pub fn stdout_is(runcmd: &Runcmd, text: &str) { #[step] pub fn stdout_isnt(runcmd: &Runcmd, text: &str) { if check_matches(runcmd, Stream::Stdout, MatchKind::Exact, text)? { - throw!(format!("stdout is exactly {:?}", text)); + throw!(format!("stdout is exactly {text:?}")); } } @@ -448,7 +448,7 @@ pub fn stdout_isnt(runcmd: &Runcmd, text: &str) { #[step] pub fn stderr_is(runcmd: &Runcmd, text: &str) { if !check_matches(runcmd, Stream::Stderr, MatchKind::Exact, text)? { - throw!(format!("stderr is not {:?}", text)); + throw!(format!("stderr is not {text:?}")); } } @@ -461,7 +461,7 @@ pub fn stderr_is(runcmd: &Runcmd, text: &str) { #[step] pub fn stderr_isnt(runcmd: &Runcmd, text: &str) { if check_matches(runcmd, Stream::Stderr, MatchKind::Exact, text)? { - throw!(format!("stderr is exactly {:?}", text)); + throw!(format!("stderr is exactly {text:?}")); } } @@ -474,7 +474,7 @@ pub fn stderr_isnt(runcmd: &Runcmd, text: &str) { #[step] pub fn stdout_contains(runcmd: &Runcmd, text: &str) { if !check_matches(runcmd, Stream::Stdout, MatchKind::Contains, text)? { - throw!(format!("stdout does not contain {:?}", text)); + throw!(format!("stdout does not contain {text:?}")); } } @@ -487,7 +487,7 @@ pub fn stdout_contains(runcmd: &Runcmd, text: &str) { #[step] pub fn stdout_doesnt_contain(runcmd: &Runcmd, text: &str) { if check_matches(runcmd, Stream::Stdout, MatchKind::Contains, text)? { - throw!(format!("stdout contains {:?}", text)); + throw!(format!("stdout contains {text:?}")); } } @@ -500,7 +500,7 @@ pub fn stdout_doesnt_contain(runcmd: &Runcmd, text: &str) { #[step] pub fn stderr_contains(runcmd: &Runcmd, text: &str) { if !check_matches(runcmd, Stream::Stderr, MatchKind::Contains, text)? { - throw!(format!("stderr does not contain {:?}", text)); + throw!(format!("stderr does not contain {text:?}")); } } @@ -513,7 +513,7 @@ pub fn stderr_contains(runcmd: &Runcmd, text: &str) { #[step] pub fn stderr_doesnt_contain(runcmd: &Runcmd, text: &str) { if check_matches(runcmd, Stream::Stderr, MatchKind::Contains, text)? { - throw!(format!("stderr contains {:?}", text)); + throw!(format!("stderr contains {text:?}")); } } @@ -527,7 +527,7 @@ pub fn stderr_doesnt_contain(runcmd: &Runcmd, text: &str) { #[step] pub fn stdout_matches_regex(runcmd: &Runcmd, regex: &str) { if !check_matches(runcmd, Stream::Stdout, MatchKind::Regex, regex)? { - throw!(format!("stdout does not match {:?}", regex)); + throw!(format!("stdout does not match {regex:?}")); } } @@ -541,7 +541,7 @@ pub fn stdout_matches_regex(runcmd: &Runcmd, regex: &str) { #[step] pub fn stdout_doesnt_match_regex(runcmd: &Runcmd, regex: &str) { if check_matches(runcmd, Stream::Stdout, MatchKind::Regex, regex)? { - throw!(format!("stdout matches {:?}", regex)); + throw!(format!("stdout matches {regex:?}")); } } @@ -555,7 +555,7 @@ pub fn stdout_doesnt_match_regex(runcmd: &Runcmd, regex: &str) { #[step] pub fn stderr_matches_regex(runcmd: &Runcmd, regex: &str) { if !check_matches(runcmd, Stream::Stderr, MatchKind::Regex, regex)? { - throw!(format!("stderr does not match {:?}", regex)); + throw!(format!("stderr does not match {regex:?}")); } } @@ -569,6 +569,6 @@ pub fn stderr_matches_regex(runcmd: &Runcmd, regex: &str) { #[step] pub fn stderr_doesnt_match_regex(runcmd: &Runcmd, regex: &str) { if check_matches(runcmd, Stream::Stderr, MatchKind::Regex, regex)? { - throw!(format!("stderr matches {:?}", regex)); + throw!(format!("stderr matches {regex:?}")); } } diff --git a/subplotlib/subplot-rust-support.rs b/subplotlib/subplot-rust-support.rs index 4763eff..95dc3f5 100644 --- a/subplotlib/subplot-rust-support.rs +++ b/subplotlib/subplot-rust-support.rs @@ -61,8 +61,6 @@ set -eu exec '{target_path}/{bin_name}' --resources '{src_dir}/share' "$@" "#, target_path = target_path.display(), - bin_name = bin_name, - src_dir = src_dir, ), )?; { @@ -92,21 +90,21 @@ fn uninstall_subplot(context: &mut SubplotContext) { #[step] #[context(Runcmd)] fn scenario_was_run(context: &ScenarioContext, name: &str) { - let text = format!("\nscenario: {}\n", name); + let text = format!("\nscenario: {name}\n"); runcmd::stdout_contains::call(context, &text)?; } #[step] #[context(Runcmd)] fn scenario_was_not_run(context: &ScenarioContext, name: &str) { - let text = format!("\nscenario: {}\n", name); + let text = format!("\nscenario: {name}\n"); runcmd::stdout_doesnt_contain::call(context, &text)?; } #[step] #[context(Runcmd)] fn step_was_run(context: &ScenarioContext, keyword: &str, name: &str) { - let text = format!("\n step: {} {}\n", keyword, name); + let text = format!("\n step: {keyword} {name}\n"); runcmd::stdout_contains::call(context, &text)?; } @@ -119,10 +117,7 @@ fn step_was_run_and_then( keyword2: &str, name2: &str, ) { - let text = format!( - "\n step: {} {}\n step: {} {}", - keyword1, name1, keyword2, name2 - ); + let text = format!("\n step: {keyword1} {name1}\n step: {keyword2} {name2}"); runcmd::stdout_contains::call(context, &text)?; } @@ -135,17 +130,14 @@ fn cleanup_was_run( keyword2: &str, name2: &str, ) { - let text = format!( - "\n cleanup: {} {}\n cleanup: {} {}\n", - keyword1, name1, keyword2, name2 - ); + let text = format!("\n cleanup: {keyword1} {name1}\n cleanup: {keyword2} {name2}\n"); runcmd::stdout_contains::call(context, &text)?; } #[step] #[context(Runcmd)] fn cleanup_was_not_run(context: &ScenarioContext, keyword: &str, name: &str) { - let text = format!("\n cleanup: {} {}\n", keyword, name); + let text = format!("\n cleanup: {keyword} {name}\n"); runcmd::stdout_doesnt_contain::call(context, &text)?; } @@ -162,7 +154,7 @@ fn end_of_file(context: &Datadir, filename: &str, nbytes: usize) -> Vec<u8> { fn file_ends_in_zero_newlines(context: &Datadir, filename: &str) { let b = end_of_file(context, filename, 1)?; if b[0] == b'\n' { - throw!(format!("File {} ends in unexpected newline", filename)); + throw!(format!("File {filename} ends in unexpected newline")); } } @@ -171,8 +163,7 @@ fn file_ends_in_one_newline(context: &Datadir, filename: &str) { let b = end_of_file(context, filename, 2)?; if !(b[0] != b'\n' && b[1] == b'\n') { throw!(format!( - "File {} does not end in exactly one newline", - filename + "File {filename} does not end in exactly one newline", )); } } @@ -182,8 +173,7 @@ fn file_ends_in_two_newlines(context: &Datadir, filename: &str) { let b = end_of_file(context, filename, 2)?; if b[0] != b'\n' || b[1] != b'\n' { throw!(format!( - "File {} does not end in exactly two newlines", - filename + "File {filename} does not end in exactly two newlines", )); } } @@ -209,12 +199,11 @@ fn json_output_matches_file(context: &ScenarioContext, filename: &str) { let output: serde_json::Value = serde_json::from_str(&output)?; let fcontent: serde_json::Value = serde_json::from_str(&fcontent)?; println!("########"); - println!("Output:\n{:#}", output); - println!("File:\n{:#}", fcontent); + println!("Output:\n{output:#}"); + println!("File:\n{fcontent:#}"); println!("########"); assert_eq!( output, fcontent, - "Command output does not match the content of {}", - filename + "Command output does not match the content of {filename}", ); } diff --git a/tests/bindings-ubm.rs b/tests/bindings-ubm.rs index dc3be19..0ee59e5 100644 --- a/tests/bindings-ubm.rs +++ b/tests/bindings-ubm.rs @@ -16,7 +16,7 @@ fn bindings_microbenchmark() { let mut texts = vec![]; for i in 0..N { - texts.push(format!("step {}", i)); + texts.push(format!("step {i}")); } let texted = time.elapsed().unwrap(); @@ -24,7 +24,7 @@ fn bindings_microbenchmark() { for t in texts.iter() { re.push(( t, - RegexBuilder::new(&format!("^{}$", t)) + RegexBuilder::new(&format!("^{t}$")) .case_insensitive(false) .build() .unwrap(), |