diff --git a/src/exec/command.rs b/src/exec/command.rs index 31cac83..960fa49 100644 --- a/src/exec/command.rs +++ b/src/exec/command.rs @@ -29,12 +29,11 @@ pub fn execute_command(mut cmd: Command, out_perm: Arc>) { let _ = stdout.lock().write_all(&output.stdout); let _ = stderr.lock().write_all(&output.stderr); } + Err(ref why) if why.kind() == io::ErrorKind::NotFound => { + eprintln!("fd: execution error: command not found"); + } Err(why) => { - if why.kind() == io::ErrorKind::NotFound { - eprintln!("fd: execution error: command not found"); - } else { - eprintln!("fd: execution error: {}", why); - } + eprintln!("fd: execution error: {}", why); } } } diff --git a/src/fshelper/mod.rs b/src/fshelper/mod.rs index 10db0f2..3ccf713 100644 --- a/src/fshelper/mod.rs +++ b/src/fshelper/mod.rs @@ -17,11 +17,11 @@ use ignore::DirEntry; pub fn path_absolute_form(path: &Path) -> io::Result { if path.is_absolute() { - Ok(path.to_path_buf()) - } else { - let path = path.strip_prefix(".").unwrap_or(path); - current_dir().map(|path_buf| path_buf.join(path)) + return Ok(path.to_path_buf()); } + + let path = path.strip_prefix(".").unwrap_or(path); + current_dir().map(|path_buf| path_buf.join(path)) } pub fn absolute_path(path: &Path) -> io::Result { @@ -42,11 +42,7 @@ pub fn absolute_path(path: &Path) -> io::Result { // Path::is_dir() is not guaranteed to be intuitively correct for "." and ".." // See: https://github.com/rust-lang/rust/issues/45302 pub fn is_dir(path: &Path) -> bool { - if path.file_name().is_some() { - path.is_dir() - } else { - path.is_dir() && path.canonicalize().is_ok() - } + path.is_dir() && (path.file_name().is_some() || path.canonicalize().is_ok()) } #[cfg(any(unix, target_os = "redox"))] diff --git a/src/internal.rs b/src/internal.rs index 3cce716..197f4f6 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -66,20 +66,11 @@ impl SizeFilter { return None; } - let captures = match SIZE_CAPTURES.captures(s) { - Some(cap) => cap, - None => return None, - }; - + let captures = SIZE_CAPTURES.captures(s)?; let limit_kind = captures.get(1).map_or("+", |m| m.as_str()); - - let quantity = match captures.get(2) { - None => return None, - Some(v) => match v.as_str().parse::() { - Ok(val) => val, - _ => return None, - }, - }; + let quantity = captures + .get(2) + .and_then(|v| v.as_str().parse::().ok())?; let multiplier = match &captures.get(3).map_or("b", |m| m.as_str()).to_lowercase()[..] { v if v.starts_with("ki") => KIBI,