clippy cleanup
This commit is contained in:
parent
420bd0483c
commit
acd33980e9
3 changed files with 13 additions and 12 deletions
4
build.rs
4
build.rs
|
@ -14,9 +14,9 @@ fn main() -> Result<(), String> {
|
|||
// a more robust way of doing this would be to use vergen (https://github.com/rustyhorde/vergen), but it pulls in a
|
||||
// whole bunch of extra dependencies (including chrono and git2), and also blocks compilation on the current MSRV.
|
||||
// this method is less clever and robust, but it works!
|
||||
let git = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output();
|
||||
let git = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output();
|
||||
let hash = match git {
|
||||
Ok(output) => String::from_utf8_lossy(&*output.stdout).into(),
|
||||
Ok(output) => String::from_utf8_lossy(&output.stdout).into(),
|
||||
Err(_) => {
|
||||
// git not being present (or failing) shouldn't block compilation
|
||||
println!("cargo:warning=Failed to retrieve git commit hash");
|
||||
|
|
|
@ -163,10 +163,10 @@ fn main() {
|
|||
// handles: --prompt never --overwrite
|
||||
// user specified --prompt never in conjunction with --overwrite, so always rename
|
||||
true
|
||||
} else if prompt == Prompt::Error || ask(&*format!("Rename {:#?} to {:#?}?", &f.file, &rename_to)) {
|
||||
} else if prompt == Prompt::Error || ask(&format!("Rename {:#?} to {:#?}?", &f.file, &rename_to)) {
|
||||
// handles: --prompt error --overwrite, --prompt always --overwrite [y]
|
||||
// if the target exists, prompt before renaming; otherwise, just rename
|
||||
!rename_to.exists() || ask(&*format!("Destination {:#?} already exists, overwrite?", rename_to))
|
||||
!rename_to.exists() || ask(&format!("Destination {:#?} already exists, overwrite?", rename_to))
|
||||
} else {
|
||||
// handles: --prompt always --overwrite [n]
|
||||
// user was prompted and replied "no"
|
||||
|
@ -191,7 +191,7 @@ fn main() {
|
|||
warn!("Couldn't rename {:#?} to {:#?}: {:#?}", f.file, rename_to, e);
|
||||
// if the user passed --prompt never, continue to the next file
|
||||
// otherwise, prompt user to retry move, retrying until the rename succeeds or they respond "N"
|
||||
if prompt == Prompt::Never || !ask(&*format!("Error while renaming file: {:#?}. Try again?", e)) {
|
||||
if prompt == Prompt::Never || !ask(&format!("Error while renaming file: {:#?}. Try again?", e)) {
|
||||
failed += 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -102,11 +102,12 @@ fn simple_directory() {
|
|||
set_current_dir(dir.path()).expect("Failed to change directory.");
|
||||
|
||||
for (name, bytes) in &files {
|
||||
let mut file = File::create(dir.path().join(name)).expect(&*format!("Failed to create file: {}", name));
|
||||
let mut file = File::create(dir.path().join(name))
|
||||
.unwrap_or_else(|_| panic!("Failed to create file: {}", name));
|
||||
|
||||
file
|
||||
.write_all(bytes)
|
||||
.expect(&*format!("Failed to write to file: {}", name));
|
||||
.unwrap_or_else(|_| panic!("Failed to write to file: {}", name));
|
||||
drop(file);
|
||||
}
|
||||
|
||||
|
@ -225,7 +226,7 @@ fn argument_parsing() {
|
|||
#[test]
|
||||
/// Ensure that `fif -e jpg dir` is interpreted as "scan for jpg files in dir" and not "scan for jpg and dir files"
|
||||
fn positional_args() {
|
||||
for flag in &["-x", "-e", "-X", "-E"] {
|
||||
for flag in ["-x", "-e", "-X", "-E"] {
|
||||
assert_eq!(
|
||||
Parameters::parse_from(vec!["fif", flag, "images", "directory"]).dir,
|
||||
PathBuf::from("directory")
|
||||
|
@ -483,8 +484,8 @@ fn media_contains_audio_video_images() {
|
|||
.for_each(|ext| assert!(media_exts.contains(&ext)));
|
||||
|
||||
assert_eq!(
|
||||
Parameters::parse_from(&["fif", "-E", "media"]).extensions(),
|
||||
Parameters::parse_from(&["fif", "-E", "audio,video,images"]).extensions()
|
||||
Parameters::parse_from(["fif", "-E", "media"]).extensions(),
|
||||
Parameters::parse_from(["fif", "-E", "audio,video,images"]).extensions()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -510,7 +511,7 @@ fn writables_is_correct() {
|
|||
fn verbosity() {
|
||||
use log::LevelFilter;
|
||||
assert!(
|
||||
Parameters::try_parse_from(&["fif", "-q", "-v"]).is_err(),
|
||||
Parameters::try_parse_from(["fif", "-q", "-v"]).is_err(),
|
||||
"Failed to reject usage of both -q and -v!"
|
||||
);
|
||||
|
||||
|
@ -527,7 +528,7 @@ fn verbosity() {
|
|||
];
|
||||
|
||||
for (flags, level) in expected_results {
|
||||
assert_eq!(Parameters::parse_from(&["fif", flags]).get_verbosity(), level);
|
||||
assert_eq!(Parameters::parse_from(["fif", flags]).get_verbosity(), level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue