mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-04 15:07:47 +00:00
refactor/polish ~ fix cargo clippy
complaints (collapse else-if)
This commit is contained in:
parent
2db6fb20c9
commit
b8eb763e43
8 changed files with 26 additions and 42 deletions
|
@ -202,14 +202,12 @@ fn determine_backup_suffix(backup_mode: BackupMode, matches: &getopts::Matches)
|
|||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let (Ok(s), BackupMode::SimpleBackup) = (env::var("SIMPLE_BACKUP_SUFFIX"), backup_mode) {
|
||||
} else if let (Ok(s), BackupMode::SimpleBackup) = (env::var("SIMPLE_BACKUP_SUFFIX"), backup_mode) {
|
||||
s
|
||||
} else {
|
||||
"~".to_owned()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn help(usage: &str) {
|
||||
println!(
|
||||
|
|
|
@ -115,14 +115,12 @@ fn num_cpus_all() -> usize {
|
|||
// In some situation, /proc and /sys are not mounted, and sysconf returns 1.
|
||||
// However, we want to guarantee that `nproc --all` >= `nproc`.
|
||||
num_cpus::get()
|
||||
} else {
|
||||
if nprocs > 0 {
|
||||
} else if nprocs > 0 {
|
||||
nprocs as usize
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Other platform(e.g., windows), num_cpus::get() directly.
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd",
|
||||
|
|
|
@ -290,13 +290,11 @@ impl Pinky {
|
|||
if ut.is_user_process() {
|
||||
if self.names.is_empty() {
|
||||
self.print_entry(&ut)
|
||||
} else {
|
||||
if self.names.iter().any(|n| n.as_str() == ut.user()) {
|
||||
} else if self.names.iter().any(|n| n.as_str() == ut.user()) {
|
||||
self.print_entry(&ut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -27,14 +27,12 @@ fn has_enough_digits(
|
|||
} else {
|
||||
false //undecidable without converting
|
||||
}
|
||||
} else {
|
||||
if hex_input {
|
||||
} else if hex_input {
|
||||
((((string_position - 1) - starting_position) * 9) / 8 >= limit)
|
||||
} else {
|
||||
((string_position - 1) - starting_position >= limit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FloatAnalysis {
|
||||
pub fn analyze(
|
||||
|
|
|
@ -189,15 +189,13 @@ fn read_input(input_files: &[String], config: &Config) -> HashMap<String, (Vec<S
|
|||
let mut files = Vec::new();
|
||||
if input_files.is_empty() {
|
||||
files.push("-");
|
||||
} else {
|
||||
if config.gnu_ext {
|
||||
} else if config.gnu_ext {
|
||||
for file in input_files {
|
||||
files.push(&file);
|
||||
}
|
||||
} else {
|
||||
files.push(&input_files[0]);
|
||||
}
|
||||
}
|
||||
let mut lines_so_far: usize = 0;
|
||||
for filename in files {
|
||||
let reader: BufReader<Box<dyn Read>> = BufReader::new(if filename == "-" {
|
||||
|
|
|
@ -225,8 +225,7 @@ fn handle_dir(path: &Path, options: &Options) -> bool {
|
|||
}
|
||||
} else if options.dir && (!is_root || !options.preserve_root) {
|
||||
had_err = remove_dir(path, options).bitor(had_err);
|
||||
} else {
|
||||
if options.recursive {
|
||||
} else if options.recursive {
|
||||
show_error!("could not remove directory '{}'", path.display());
|
||||
had_err = true;
|
||||
} else {
|
||||
|
@ -236,7 +235,6 @@ fn handle_dir(path: &Path, options: &Options) -> bool {
|
|||
);
|
||||
had_err = true;
|
||||
}
|
||||
}
|
||||
|
||||
had_err
|
||||
}
|
||||
|
|
|
@ -302,13 +302,11 @@ fn exec(files: Vec<String>, settings: &Settings) -> i32 {
|
|||
} else {
|
||||
print_sorted(file_merger, &settings.outfile)
|
||||
}
|
||||
} else {
|
||||
if settings.unique {
|
||||
} else if settings.unique {
|
||||
print_sorted(lines.iter().dedup(), &settings.outfile)
|
||||
} else {
|
||||
print_sorted(lines.iter(), &settings.outfile)
|
||||
}
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
|
|
|
@ -182,12 +182,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
if let Err(e) = set_symlink_file_times(path, atime, mtime) {
|
||||
show_warning!("cannot touch '{}': {}", path, e);
|
||||
}
|
||||
} else {
|
||||
if let Err(e) = filetime::set_file_times(path, atime, mtime) {
|
||||
} else if let Err(e) = filetime::set_file_times(path, atime, mtime) {
|
||||
show_warning!("cannot touch '{}': {}", path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue