mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-10-26 22:21:58 +03:00
Fix clippy suggestions
This commit is contained in:
parent
f443195d92
commit
f5de5487cc
2
.github/workflows/CICD.yml
vendored
2
.github/workflows/CICD.yml
vendored
@ -1,7 +1,7 @@
|
|||||||
name: CICD
|
name: CICD
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MIN_SUPPORTED_RUST_VERSION: "1.54.0"
|
MIN_SUPPORTED_RUST_VERSION: "1.57.0"
|
||||||
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
|
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
@ -208,7 +208,7 @@ Hyperfine can be installed from source via [cargo](https://doc.rust-lang.org/car
|
|||||||
cargo install hyperfine
|
cargo install hyperfine
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure that you use Rust 1.54 or higher.
|
Make sure that you use Rust 1.57 or higher.
|
||||||
|
|
||||||
### From binaries (Linux, macOS, Windows)
|
### From binaries (Linux, macOS, Windows)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ impl fmt::Display for ParameterScanError {
|
|||||||
|
|
||||||
impl Error for ParameterScanError {}
|
impl Error for ParameterScanError {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum OptionsError<'a> {
|
pub enum OptionsError<'a> {
|
||||||
EmptyRunsRange,
|
EmptyRunsRange,
|
||||||
TooManyCommandNames(usize),
|
TooManyCommandNames(usize),
|
||||||
|
@ -74,12 +74,10 @@ fn table_row(entry: &BenchmarkResultWithRelativeSpeed, unit: Unit) -> Vec<u8> {
|
|||||||
let rel_str = format!("{:.2}", entry.relative_speed);
|
let rel_str = format!("{:.2}", entry.relative_speed);
|
||||||
let rel_stddev_str = if entry.is_fastest {
|
let rel_stddev_str = if entry.is_fastest {
|
||||||
"".into()
|
"".into()
|
||||||
|
} else if let Some(stddev) = entry.relative_speed_stddev {
|
||||||
|
format!(" ± {:.2}", stddev)
|
||||||
} else {
|
} else {
|
||||||
if let Some(stddev) = entry.relative_speed_stddev {
|
"".into()
|
||||||
format!(" ± {:.2}", stddev)
|
|
||||||
} else {
|
|
||||||
"".into()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
|
@ -63,12 +63,10 @@ fn add_table_row(dest: &mut Vec<u8>, entry: &BenchmarkResultWithRelativeSpeed, u
|
|||||||
let rel_str = format!("{:.2}", entry.relative_speed);
|
let rel_str = format!("{:.2}", entry.relative_speed);
|
||||||
let rel_stddev_str = if entry.is_fastest {
|
let rel_stddev_str = if entry.is_fastest {
|
||||||
"".into()
|
"".into()
|
||||||
|
} else if let Some(stddev) = entry.relative_speed_stddev {
|
||||||
|
format!(" ± {:.2}", stddev)
|
||||||
} else {
|
} else {
|
||||||
if let Some(stddev) = entry.relative_speed_stddev {
|
"".into()
|
||||||
format!(" ± {:.2}", stddev)
|
|
||||||
} else {
|
|
||||||
"".into()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dest.extend(
|
dest.extend(
|
||||||
|
@ -261,7 +261,7 @@ fn build_export_manager(matches: &ArgMatches) -> io::Result<ExportManager> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build the commands to benchmark
|
/// Build the commands to benchmark
|
||||||
fn build_commands<'a>(matches: &'a ArgMatches) -> Vec<Command<'a>> {
|
fn build_commands(matches: &ArgMatches) -> Vec<Command> {
|
||||||
let command_names = matches.values_of("command-name");
|
let command_names = matches.values_of("command-name");
|
||||||
let command_strings = matches.values_of("command").unwrap();
|
let command_strings = matches.values_of("command").unwrap();
|
||||||
|
|
||||||
|
@ -182,25 +182,21 @@ fn test_shell_parse_command() {
|
|||||||
assert_eq!(&s, "shell -x 'aaa bbb'");
|
assert_eq!(&s, "shell -x 'aaa bbb'");
|
||||||
|
|
||||||
let cmd = shell.command();
|
let cmd = shell.command();
|
||||||
// Command::get_program and Command::args are not yet available in stable channel.
|
assert_eq!(cmd.get_program().to_string_lossy(), "shell");
|
||||||
// https://doc.rust-lang.org/std/process/struct.Command.html#method.get_program
|
assert_eq!(
|
||||||
let s = format!("{:?}", cmd);
|
cmd.get_args()
|
||||||
assert_eq!(&s, r#""shell" "-x" "aaa bbb""#);
|
.map(|a| a.to_string_lossy())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
vec!["-x", "aaa bbb"]
|
||||||
|
);
|
||||||
|
|
||||||
// Error cases
|
// Error cases
|
||||||
|
assert!(matches!(
|
||||||
|
Shell::parse("shell 'foo").unwrap_err(),
|
||||||
|
OptionsError::ShellParseError(_)
|
||||||
|
));
|
||||||
|
|
||||||
match Shell::parse("shell 'foo").unwrap_err() {
|
assert_eq!(Shell::parse("").unwrap_err(), OptionsError::EmptyShell);
|
||||||
OptionsError::ShellParseError(_) => { /* ok */ }
|
|
||||||
e => assert!(false, "Unexpected error: {}", e),
|
|
||||||
}
|
|
||||||
|
|
||||||
match Shell::parse("").unwrap_err() {
|
assert_eq!(Shell::parse("''").unwrap_err(), OptionsError::EmptyShell);
|
||||||
OptionsError::EmptyShell => { /* ok */ }
|
|
||||||
e => assert!(false, "Unexpected error: {}", e),
|
|
||||||
}
|
|
||||||
|
|
||||||
match Shell::parse("''").unwrap_err() {
|
|
||||||
OptionsError::EmptyShell => { /* ok */ }
|
|
||||||
e => assert!(false, "Unexpected error: {}", e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user