mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
style: simplify string interpolation
This commit is contained in:
1 parent
e8ff88dad1
commit
ef1263279d
13 files changed
+30
-33
No files matched your search
@@ -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"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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)?;
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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}"),
|
||||
]))
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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}'"))
|
||||
}
|
||||
@@ -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"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user