From 0bda339cd629b4c6d8be8267626c80313f7c1fea Mon Sep 17 00:00:00 2001 From: nivekuil Date: Wed, 2 Sep 2020 09:39:38 -0700 Subject: [PATCH] Appease clippy --- src/main.rs | 4 ++-- src/util.rs | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5753137..82a9ab0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,8 +20,8 @@ use errors::*; include!("util.rs"); -const GRAVEYARD: &'static str = "/tmp/graveyard"; -const RECORD: &'static str = ".record"; +const GRAVEYARD: &str = "/tmp/graveyard"; +const RECORD: &str = ".record"; const LINES_TO_INSPECT: usize = 6; const FILES_TO_INSPECT: usize = 6; const BIG_FILE_THRESHOLD: u64 = 500000000; // 500 MB diff --git a/src/util.rs b/src/util.rs index 95e6950..c54442a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -15,7 +15,7 @@ fn symlink_exists>(path: P) -> bool { } fn get_user() -> String { - env::var("USER").unwrap_or(String::from("unknown")) + env::var("USER").unwrap_or_else(|_| String::from("unknown")) } /// Prompt for user input, returning True if the first character is 'y' or 'Y' @@ -29,7 +29,7 @@ fn prompt_yes>(prompt: T) -> bool { stdin.bytes().next() .and_then(|c| c.ok()) .map(|c| c as char) - .and_then(|c| Some(c == 'y' || c == 'Y')) + .map(|c| (c == 'y' || c == 'Y')) .unwrap_or(false) } @@ -39,8 +39,7 @@ fn rename_grave>(grave: G) -> PathBuf { let name = grave.to_str().expect("Filename must be valid unicode."); (1_u64..) .map(|i| PathBuf::from(format!("{}~{}", name, i))) - .skip_while(|p| symlink_exists(p)) - .next() + .find(|p| !symlink_exists(p)) .expect("Failed to rename duplicate file or directory") }