diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs index d0e748e..098451b 100644 --- a/src/benchmark/executor.rs +++ b/src/benchmark/executor.rs @@ -54,7 +54,7 @@ fn run_command_and_measure_common( ); let result = execute_and_measure(command) - .with_context(|| format!("Failed to run command '{}'", command_name))?; + .with_context(|| format!("Failed to run command '{command_name}'"))?; if command_failure_action == CmdFailureAction::RaiseError && !result.status.success() { bail!( @@ -62,7 +62,7 @@ fn run_command_and_measure_common( Alternatively, use the '--show-output' option to debug what went wrong.", result.status.code().map_or( "The process has been terminated by a signal".into(), - |c| format!("Command terminated with non-zero exit code: {}", c) + |c| format!("Command terminated with non-zero exit code: {c}") ) ); } diff --git a/src/benchmark/mod.rs b/src/benchmark/mod.rs index 658494d..35c0e27 100644 --- a/src/benchmark/mod.rs +++ b/src/benchmark/mod.rs @@ -312,7 +312,7 @@ impl<'a> Benchmark<'a> { let (mean_str, time_unit) = format_duration_unit(t_mean, self.options.time_unit); let min_str = format_duration(t_min, Some(time_unit)); let max_str = format_duration(t_max, Some(time_unit)); - let num_str = format!("{} runs", t_num); + let num_str = format!("{t_num} runs"); let user_str = format_duration(user_mean, Some(time_unit)); let system_str = format_duration(system_mean, Some(time_unit)); diff --git a/src/benchmark/scheduler.rs b/src/benchmark/scheduler.rs index 62f3e63..941fa5a 100644 --- a/src/benchmark/scheduler.rs +++ b/src/benchmark/scheduler.rs @@ -86,7 +86,7 @@ impl<'a> Scheduler<'a> { "{}{} times faster than {}", format!("{:8.2}", item.relative_speed).bold().green(), if let Some(stddev) = item.relative_speed_stddev { - format!(" ± {}", format!("{:.2}", stddev).green()) + format!(" ± {}", format!("{stddev:.2}").green()) } else { "".into() }, @@ -104,7 +104,7 @@ impl<'a> Scheduler<'a> { if item.is_fastest { " ".into() } else if let Some(stddev) = item.relative_speed_stddev { - format!(" ± {}", format!("{:5.2}", stddev).green()) + format!(" ± {}", format!("{stddev:5.2}").green()) } else { " ".into() }, diff --git a/src/command.rs b/src/command.rs index f580691..1c4dea9 100644 --- a/src/command.rs +++ b/src/command.rs @@ -62,13 +62,13 @@ impl<'a> Command<'a> { let parameters = self .get_unused_parameters() .fold(String::new(), |output, (parameter, value)| { - output + &format!("{} = {}, ", parameter, value) + output + &format!("{parameter} = {value}, ") }); let parameters = parameters.trim_end_matches(", "); let parameters = if parameters.is_empty() { "".into() } else { - format!(" ({})", parameters) + format!(" ({parameters})") }; format!("{}{}", self.get_name(), parameters) @@ -81,7 +81,7 @@ impl<'a> Command<'a> { pub fn get_command(&self) -> Result { let command_line = self.get_command_line(); let mut tokens = shell_words::split(&command_line) - .with_context(|| format!("Failed to parse command '{}'", command_line))? + .with_context(|| format!("Failed to parse command '{command_line}'"))? .into_iter(); if let Some(program_name) = tokens.next() { @@ -100,7 +100,7 @@ impl<'a> Command<'a> { pub fn get_unused_parameters(&self) -> impl Iterator { self.parameters .iter() - .filter(move |(parameter, _)| !self.expression.contains(&format!("{{{}}}", parameter))) + .filter(move |(parameter, _)| !self.expression.contains(&format!("{{{parameter}}}"))) } fn replace_parameters_in(&self, original: &str) -> String { @@ -108,7 +108,7 @@ impl<'a> Command<'a> { let mut replacements = BTreeMap::::new(); for (param_name, param_value) in &self.parameters { replacements.insert( - format!("{{{param_name}}}", param_name = param_name), + format!("{{{param_name}}}"), param_value.to_string(), ); } diff --git a/src/export/asciidoc.rs b/src/export/asciidoc.rs index c956617..f1323fc 100644 --- a/src/export/asciidoc.rs +++ b/src/export/asciidoc.rs @@ -32,7 +32,7 @@ impl MarkupExporter for AsciidocExporter { } fn command(&self, cmd: &str) -> String { - format!("`{}`", cmd) + format!("`{cmd}`") } } @@ -71,8 +71,7 @@ fn test_asciidoc_exporter_table_header() { #[cfg(test)] fn cfg_test_table_header(unit_short_name: &str) -> String { format!( - "[cols=\"<,>,>,>,>\"]\n|===\n| Command \n| Mean [{unit}] \n| Min [{unit}] \n| Max [{unit}] \n| Relative \n", - unit = unit_short_name + "[cols=\"<,>,>,>,>\"]\n|===\n| Command \n| Mean [{unit_short_name}] \n| Min [{unit_short_name}] \n| Max [{unit_short_name}] \n| Relative \n" ) } diff --git a/src/export/csv.rs b/src/export/csv.rs index b91c8de..7c7d0ee 100644 --- a/src/export/csv.rs +++ b/src/export/csv.rs @@ -31,7 +31,7 @@ impl Exporter for CsvExporter { .collect(); if let Some(res) = results.first() { for param_name in res.parameters.keys() { - headers.push(Cow::Owned(format!("parameter_{}", param_name).into_bytes())); + headers.push(Cow::Owned(format!("parameter_{param_name}").into_bytes())); } } writer.write_record(headers)?; diff --git a/src/export/markdown.rs b/src/export/markdown.rs index 94e452b..c4d5fd1 100644 --- a/src/export/markdown.rs +++ b/src/export/markdown.rs @@ -24,7 +24,7 @@ impl MarkupExporter for MarkdownExporter { } fn command(&self, cmd: &str) -> String { - format!("`{}`", cmd) + format!("`{cmd}`") } } @@ -53,8 +53,7 @@ fn test_markdown_formatter_table_divider() { #[cfg(test)] fn cfg_test_table_header(unit_short_name: String) -> String { format!( - "| Command | Mean [{unit}] | Min [{unit}] | Max [{unit}] | Relative |\n|:---|---:|---:|---:|---:|\n", - unit = unit_short_name + "| Command | Mean [{unit_short_name}] | Min [{unit_short_name}] | Max [{unit_short_name}] | Relative |\n|:---|---:|---:|---:|---:|\n" ) } diff --git a/src/export/markup.rs b/src/export/markup.rs index 88bcaa9..abab3a0 100644 --- a/src/export/markup.rs +++ b/src/export/markup.rs @@ -32,9 +32,9 @@ pub trait MarkupExporter { // emit table header data table.push_str(&self.table_row(&[ "Command", - &format!("Mean {}", notation), - &format!("Min {}", notation), - &format!("Max {}", notation), + &format!("Mean {notation}"), + &format!("Min {notation}"), + &format!("Max {notation}"), "Relative", ])); @@ -59,7 +59,7 @@ pub trait MarkupExporter { let rel_stddev_str = if entry.is_fastest { "".into() } else if let Some(stddev) = entry.relative_speed_stddev { - format!(" ± {:.2}", stddev) + format!(" ± {stddev:.2}") } else { "".into() }; @@ -67,10 +67,10 @@ pub trait MarkupExporter { // prepare table row entries table.push_str(&self.table_row(&[ &self.command(&cmd_str), - &format!("{}{}", mean_str, stddev_str), + &format!("{mean_str}{stddev_str}"), &min_str, &max_str, - &format!("{}{}", rel_str, rel_stddev_str), + &format!("{rel_str}{rel_stddev_str}"), ])) } diff --git a/src/export/mod.rs b/src/export/mod.rs index 717f879..4fdab0c 100644 --- a/src/export/mod.rs +++ b/src/export/mod.rs @@ -108,7 +108,7 @@ impl ExportManager { ExportTarget::Stdout } else { let _ = File::create(filename) - .with_context(|| format!("Could not create export file '{}'", filename))?; + .with_context(|| format!("Could not create export file '{filename}'"))?; ExportTarget::File(filename.to_string()) }, }); @@ -153,5 +153,5 @@ impl ExportManager { fn write_to_file(filename: &str, content: &[u8]) -> Result<()> { let mut file = OpenOptions::new().write(true).open(filename)?; file.write_all(content) - .with_context(|| format!("Failed to export results to '{}'", filename)) + .with_context(|| format!("Failed to export results to '{filename}'")) } diff --git a/src/export/orgmode.rs b/src/export/orgmode.rs index dabc62d..65ff63f 100644 --- a/src/export/orgmode.rs +++ b/src/export/orgmode.rs @@ -18,7 +18,7 @@ impl MarkupExporter for OrgmodeExporter { } fn command(&self, cmd: &str) -> String { - format!("={}=", cmd) + format!("={cmd}=") } } @@ -58,8 +58,7 @@ fn test_orgmode_formatter_table_line() { #[cfg(test)] fn cfg_test_table_header(unit_short_name: String) -> String { format!( - "| Command | Mean [{unit}] | Min [{unit}] | Max [{unit}] | Relative |\n|--+--+--+--+--|\n", - unit = unit_short_name + "| Command | Mean [{unit_short_name}] | Min [{unit_short_name}] | Max [{unit_short_name}] | Relative |\n|--+--+--+--+--|\n" ) } diff --git a/src/options.rs b/src/options.rs index 43bb82b..7511bb7 100644 --- a/src/options.rs +++ b/src/options.rs @@ -38,7 +38,7 @@ impl Default for Shell { impl fmt::Display for Shell { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Shell::Default(cmd) => write!(f, "{}", cmd), + Shell::Default(cmd) => write!(f, "{cmd}"), Shell::Custom(cmdline) => write!(f, "{}", shell_words::join(cmdline)), } } @@ -457,7 +457,7 @@ impl Options { fn test_default_shell() { let shell = Shell::default(); - let s = format!("{}", shell); + let s = format!("{shell}"); assert_eq!(&s, DEFAULT_SHELL); let cmd = shell.command(); @@ -468,7 +468,7 @@ fn test_default_shell() { fn test_can_parse_shell_command_line_from_str() { let shell = Shell::parse_from_str("shell -x 'aaa bbb'").unwrap(); - let s = format!("{}", shell); + let s = format!("{shell}"); assert_eq!(&s, "shell -x 'aaa bbb'"); let cmd = shell.command(); diff --git a/src/parameter/mod.rs b/src/parameter/mod.rs index c766713..579a3bf 100644 --- a/src/parameter/mod.rs +++ b/src/parameter/mod.rs @@ -16,7 +16,7 @@ impl Display for ParameterValue { ParameterValue::Text(ref value) => value.clone(), ParameterValue::Numeric(value) => value.to_string(), }; - write!(f, "{}", str) + write!(f, "{str}") } } diff --git a/src/util/units.rs b/src/util/units.rs index 9528c00..4f7c730 100644 --- a/src/util/units.rs +++ b/src/util/units.rs @@ -26,7 +26,7 @@ impl Unit { /// Returns the Second value formatted for the Unit. pub fn format(self, value: Second) -> String { match self { - Unit::Second => format!("{:.3}", value), + Unit::Second => format!("{value:.3}"), Unit::MilliSecond => format!("{:.1}", value * 1e3), Unit::MicroSecond => format!("{:.1}", value * 1e6), }