diff --git a/src/cp/cp.rs b/src/cp/cp.rs index c3433f73b..baf1a9cd8 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -55,6 +55,7 @@ use std::os::unix::io::IntoRawFd; use std::os::windows::ffi::OsStrExt; use std::path::{Path, PathBuf, StripPrefixError}; use std::str::FromStr; +use std::string::ToString; use uucore::fs::{canonicalize, CanonicalizeMode}; use walkdir::WalkDir; @@ -477,7 +478,7 @@ pub fn uumain(args: Vec) -> i32 { let options = crash_if_err!(EXIT_ERR, Options::from_matches(&matches)); let paths: Vec = matches .values_of("paths") - .map(|v| v.map(std::string::ToString::to_string).collect()) + .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); let (sources, target) = crash_if_err!(EXIT_ERR, parse_path_args(&paths, &options)); @@ -593,7 +594,7 @@ impl Options { let no_target_dir = matches.is_present(OPT_NO_TARGET_DIRECTORY); let target_dir = matches .value_of(OPT_TARGET_DIRECTORY) - .map(std::string::ToString::to_string); + .map(ToString::to_string); // Parse attributes to preserve let preserve_attributes: Vec = if matches.is_present(OPT_PRESERVE) { diff --git a/src/dircolors/dircolors.rs b/src/dircolors/dircolors.rs index fa5713a88..2a485e1da 100644 --- a/src/dircolors/dircolors.rs +++ b/src/dircolors/dircolors.rs @@ -123,7 +123,7 @@ pub fn uumain(args: Vec) -> i32 { Ok(f) => { let fin = BufReader::new(f); result = parse( - fin.lines().filter_map(std::result::Result::ok), + fin.lines().filter_map(Result::ok), out_format, matches.free[0].as_str(), ) diff --git a/src/env/env.rs b/src/env/env.rs index e65ff6536..9b552165f 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -18,6 +18,7 @@ use ini::Ini; use std::borrow::Cow; use std::env; use std::io::{self, Write}; +use std::iter::Iterator; use std::process::Command; const USAGE: &str = "env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]"; @@ -160,11 +161,11 @@ fn run_env(args: Vec) -> Result<(), i32> { let null = matches.is_present("null"); let files = matches .values_of("file") - .map(std::iter::Iterator::collect) + .map(Iterator::collect) .unwrap_or_else(|| Vec::with_capacity(0)); let unsets = matches .values_of("unset") - .map(std::iter::Iterator::collect) + .map(Iterator::collect) .unwrap_or_else(|| Vec::with_capacity(0)); let mut opts = Options { diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index abbb7686f..259f6eb2e 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -32,6 +32,7 @@ use regex::Regex; use sha1::Sha1; use sha2::{Sha224, Sha256, Sha384, Sha512}; use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256}; +use std::cmp::Ordering; use std::fs::File; use std::io::{self, stdin, BufRead, BufReader, Read}; use std::path::Path; @@ -503,12 +504,8 @@ fn hashsum( } if !status { match bad_format.cmp(&1) { - std::cmp::Ordering::Equal => { - show_warning!("{} line is improperly formatted", bad_format) - } - std::cmp::Ordering::Greater => { - show_warning!("{} lines are improperly formatted", bad_format) - } + Ordering::Equal => show_warning!("{} line is improperly formatted", bad_format), + Ordering::Greater => show_warning!("{} lines are improperly formatted", bad_format), _ => {} }; if failed > 0 { diff --git a/src/install/install.rs b/src/install/install.rs index 03085d5c5..3e91ae1db 100644 --- a/src/install/install.rs +++ b/src/install/install.rs @@ -364,7 +364,7 @@ fn directory(paths: &[PathBuf], b: Behaviour) -> i32 { /// Test if the path is a a new file path that can be /// created immediately fn is_new_file_path(path: &Path) -> bool { - path.is_file() || !path.exists() && path.parent().map(std::path::Path::is_dir).unwrap_or(true) + path.is_file() || !path.exists() && path.parent().map(Path::is_dir).unwrap_or(true) } /// Perform an install, given a list of paths and behaviour. diff --git a/src/ls/ls.rs b/src/ls/ls.rs index 751e3aead..f4606f863 100644 --- a/src/ls/ls.rs +++ b/src/ls/ls.rs @@ -295,8 +295,7 @@ fn should_display(entry: &DirEntry, options: &getopts::Matches) -> bool { } fn enter_directory(dir: &PathBuf, options: &getopts::Matches) { - let mut entries: Vec<_> = - safe_unwrap!(fs::read_dir(dir).and_then(std::iter::Iterator::collect)); + let mut entries: Vec<_> = safe_unwrap!(fs::read_dir(dir).and_then(Iterator::collect)); entries.retain(|e| should_display(e, options)); diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 0fb8bf45d..50826a60c 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -18,6 +18,7 @@ extern crate uucore; use libc::{c_char, c_int, execvp}; use std::ffi::CString; use std::io::Error; +use std::ptr; const NAME: &str = "nice"; const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -120,7 +121,7 @@ process).", .map(|x| CString::new(x.as_bytes()).unwrap()) .collect(); let mut args: Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); - args.push(std::ptr::null::()); + args.push(ptr::null::()); unsafe { execvp(args[0], args.as_mut_ptr()); } diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 06561e607..7843ff565 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -123,17 +123,14 @@ With no FILE, or when FILE is -, read standard input.", let mut evec = matches .free .iter() - .map(std::string::String::as_bytes) + .map(String::as_bytes) .collect::>(); find_seps(&mut evec, sep); shuf_bytes(&mut evec, repeat, count, sep, output, random); } Mode::InputRange((b, e)) => { let rvec = (b..e).map(|x| format!("{}", x)).collect::>(); - let mut rvec = rvec - .iter() - .map(std::string::String::as_bytes) - .collect::>(); + let mut rvec = rvec.iter().map(String::as_bytes).collect::>(); shuf_bytes(&mut rvec, repeat, count, sep, output, random); } Mode::Default => { diff --git a/src/stat/fsext.rs b/src/stat/fsext.rs index 5cc214288..3a36c9296 100644 --- a/src/stat/fsext.rs +++ b/src/stat/fsext.rs @@ -15,6 +15,7 @@ pub use libc::{ S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR, }; +use std::time::UNIX_EPOCH; pub trait BirthTime { fn pretty_birth(&self) -> String; @@ -26,7 +27,7 @@ impl BirthTime for Metadata { fn pretty_birth(&self) -> String { self.created() .ok() - .and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok()) + .and_then(|t| t.duration_since(UNIX_EPOCH).ok()) .map(|e| pretty_time(e.as_secs() as i64, i64::from(e.subsec_nanos()))) .unwrap_or_else(|| "-".to_owned()) } @@ -34,7 +35,7 @@ impl BirthTime for Metadata { fn birth(&self) -> String { self.created() .ok() - .and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok()) + .and_then(|t| t.duration_since(UNIX_EPOCH).ok()) .map(|e| format!("{}", e.as_secs())) .unwrap_or_else(|| "0".to_owned()) } diff --git a/src/stat/stat.rs b/src/stat/stat.rs index d8be79f8b..3493452fd 100644 --- a/src/stat/stat.rs +++ b/src/stat/stat.rs @@ -482,12 +482,8 @@ impl Stater { ); let mut mount_list = reader .lines() - .filter_map(std::result::Result::ok) - .filter_map(|line| { - line.split_whitespace() - .nth(1) - .map(std::borrow::ToOwned::to_owned) - }) + .filter_map(Result::ok) + .filter_map(|line| line.split_whitespace().nth(1).map(ToOwned::to_owned)) .collect::>(); // Reverse sort. The longer comes first. mount_list.sort_by(|a, b| b.cmp(a)); diff --git a/src/users/users.rs b/src/users/users.rs index 57e515fc3..3d4311c4d 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -66,7 +66,7 @@ pub fn uumain(args: Vec) -> i32 { fn exec(filename: &str) { let mut users = Utmpx::iter_all_records() .read_from(filename) - .filter(uucore::utmpx::Utmpx::is_user_process) + .filter(Utmpx::is_user_process) .map(|ut| ut.user()) .collect::>(); diff --git a/src/who/who.rs b/src/who/who.rs index a1a5d8002..a83457f18 100644 --- a/src/who/who.rs +++ b/src/who/who.rs @@ -325,7 +325,7 @@ impl Who { if self.short_list { let users = Utmpx::iter_all_records() .read_from(f) - .filter(uucore::utmpx::Utmpx::is_user_process) + .filter(Utmpx::is_user_process) .map(|ut| ut.user()) .collect::>(); println!("{}", users.join(" "));