Fix clippy suggestions

This commit is contained in:
David Peter 2022-02-05 22:14:06 +01:00 committed by David Peter
parent f443195d92
commit f5de5487cc
7 changed files with 23 additions and 31 deletions

View File

@ -1,7 +1,7 @@
name: CICD
env:
MIN_SUPPORTED_RUST_VERSION: "1.54.0"
MIN_SUPPORTED_RUST_VERSION: "1.57.0"
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
on:

View File

@ -208,7 +208,7 @@ Hyperfine can be installed from source via [cargo](https://doc.rust-lang.org/car
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)

View File

@ -55,7 +55,7 @@ impl fmt::Display for ParameterScanError {
impl Error for ParameterScanError {}
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum OptionsError<'a> {
EmptyRunsRange,
TooManyCommandNames(usize),

View File

@ -74,12 +74,10 @@ fn table_row(entry: &BenchmarkResultWithRelativeSpeed, unit: Unit) -> Vec<u8> {
let rel_str = format!("{:.2}", entry.relative_speed);
let rel_stddev_str = if entry.is_fastest {
"".into()
} else if let Some(stddev) = entry.relative_speed_stddev {
format!(" ± {:.2}", stddev)
} else {
if let Some(stddev) = entry.relative_speed_stddev {
format!(" ± {:.2}", stddev)
} else {
"".into()
}
"".into()
};
format!(

View File

@ -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_stddev_str = if entry.is_fastest {
"".into()
} else if let Some(stddev) = entry.relative_speed_stddev {
format!(" ± {:.2}", stddev)
} else {
if let Some(stddev) = entry.relative_speed_stddev {
format!(" ± {:.2}", stddev)
} else {
"".into()
}
"".into()
};
dest.extend(

View File

@ -261,7 +261,7 @@ fn build_export_manager(matches: &ArgMatches) -> io::Result<ExportManager> {
}
/// 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_strings = matches.values_of("command").unwrap();

View File

@ -182,25 +182,21 @@ fn test_shell_parse_command() {
assert_eq!(&s, "shell -x 'aaa bbb'");
let cmd = shell.command();
// Command::get_program and Command::args are not yet available in stable channel.
// https://doc.rust-lang.org/std/process/struct.Command.html#method.get_program
let s = format!("{:?}", cmd);
assert_eq!(&s, r#""shell" "-x" "aaa bbb""#);
assert_eq!(cmd.get_program().to_string_lossy(), "shell");
assert_eq!(
cmd.get_args()
.map(|a| a.to_string_lossy())
.collect::<Vec<_>>(),
vec!["-x", "aaa bbb"]
);
// Error cases
assert!(matches!(
Shell::parse("shell 'foo").unwrap_err(),
OptionsError::ShellParseError(_)
));
match Shell::parse("shell 'foo").unwrap_err() {
OptionsError::ShellParseError(_) => { /* ok */ }
e => assert!(false, "Unexpected error: {}", e),
}
assert_eq!(Shell::parse("").unwrap_err(), OptionsError::EmptyShell);
match Shell::parse("").unwrap_err() {
OptionsError::EmptyShell => { /* ok */ }
e => assert!(false, "Unexpected error: {}", e),
}
match Shell::parse("''").unwrap_err() {
OptionsError::EmptyShell => { /* ok */ }
e => assert!(false, "Unexpected error: {}", e),
}
assert_eq!(Shell::parse("''").unwrap_err(), OptionsError::EmptyShell);
}