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,12 +202,10 @@ fn determine_backup_suffix(backup_mode: BackupMode, matches: &getopts::Matches)
|
|||
);
|
||||
}
|
||||
}
|
||||
} else if let (Ok(s), BackupMode::SimpleBackup) = (env::var("SIMPLE_BACKUP_SUFFIX"), backup_mode) {
|
||||
s
|
||||
} else {
|
||||
if let (Ok(s), BackupMode::SimpleBackup) = (env::var("SIMPLE_BACKUP_SUFFIX"), backup_mode) {
|
||||
s
|
||||
} else {
|
||||
"~".to_owned()
|
||||
}
|
||||
"~".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,12 +115,10 @@ 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 {
|
||||
nprocs as usize
|
||||
} else {
|
||||
if nprocs > 0 {
|
||||
nprocs as usize
|
||||
} else {
|
||||
1
|
||||
}
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -290,10 +290,8 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ 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 {
|
||||
} else {
|
||||
((string_position - 1) - starting_position >= limit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,14 +189,12 @@ 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 {
|
||||
for file in input_files {
|
||||
files.push(&file);
|
||||
}
|
||||
} else {
|
||||
files.push(&input_files[0]);
|
||||
} 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 {
|
||||
|
|
18
src/rm/rm.rs
18
src/rm/rm.rs
|
@ -225,17 +225,15 @@ 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 {
|
||||
show_error!("could not remove directory '{}'", path.display());
|
||||
had_err = true;
|
||||
} else {
|
||||
if options.recursive {
|
||||
show_error!("could not remove directory '{}'", path.display());
|
||||
had_err = true;
|
||||
} else {
|
||||
show_error!(
|
||||
"could not remove directory '{}' (did you mean to pass '-r'?)",
|
||||
path.display()
|
||||
);
|
||||
had_err = true;
|
||||
}
|
||||
show_error!(
|
||||
"could not remove directory '{}' (did you mean to pass '-r'?)",
|
||||
path.display()
|
||||
);
|
||||
had_err = true;
|
||||
}
|
||||
|
||||
had_err
|
||||
|
|
|
@ -302,12 +302,10 @@ fn exec(files: Vec<String>, settings: &Settings) -> i32 {
|
|||
} else {
|
||||
print_sorted(file_merger, &settings.outfile)
|
||||
}
|
||||
} else if settings.unique {
|
||||
print_sorted(lines.iter().dedup(), &settings.outfile)
|
||||
} else {
|
||||
if settings.unique {
|
||||
print_sorted(lines.iter().dedup(), &settings.outfile)
|
||||
} else {
|
||||
print_sorted(lines.iter(), &settings.outfile)
|
||||
}
|
||||
print_sorted(lines.iter(), &settings.outfile)
|
||||
}
|
||||
|
||||
0
|
||||
|
|
|
@ -182,10 +182,8 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue