1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 15:07:47 +00:00

refactor/polish ~ fix cargo clippy complaints (comparison_chain)

This commit is contained in:
Roy Ivy III 2019-12-29 00:43:41 -06:00
parent 2ef9c9a28e
commit 248dfbac08
2 changed files with 15 additions and 17 deletions

View file

@ -468,11 +468,11 @@ fn hashsum(
}
}
if !status {
if bad_format == 1 {
show_warning!("{} line is improperly formatted", bad_format);
} else if bad_format > 1 {
show_warning!("{} lines are improperly formatted", bad_format);
}
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),
_ => {}
};
if failed > 0 {
show_warning!("{} computed checksum did NOT match", failed);
}

View file

@ -137,11 +137,11 @@ fn process_utmpx() -> (Option<time_t>, usize) {
}
fn print_nusers(nusers: usize) {
if nusers == 1 {
print!("1 user, ");
} else if nusers > 1 {
print!("{} users, ", nusers);
}
match nusers.cmp(&1) {
std::cmp::Ordering::Equal => print!("1 user, "),
std::cmp::Ordering::Greater => print!("{} users, ", nusers),
_ => {}
};
}
fn print_time() {
@ -188,11 +188,9 @@ fn print_uptime(upsecs: i64) {
let updays = upsecs / 86400;
let uphours = (upsecs - (updays * 86400)) / 3600;
let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60;
if updays == 1 {
print!("up {:1} day, {:2}:{:02}, ", updays, uphours, upmins);
} else if updays > 1 {
print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins);
} else {
print!("up {:2}:{:02}, ", uphours, upmins);
}
match updays.cmp(&1) {
std::cmp::Ordering::Equal => print!("up {:1} day, {:2}:{:02}, ", updays, uphours, upmins),
std::cmp::Ordering::Greater => print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins),
_ => print!("up {:2}:{:02}, ", uphours, upmins),
};
}