Skip to content

Commit

Permalink
don't show as 0% a non-zero ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed Aug 4, 2024
1 parent d1cdadf commit 7fc2aef
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ fn format_ratio(n: u32, d: u32) -> String {
let r = r.round_ties_even();
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
let r = u8::try_from(r as u64).unwrap_or(255);
if r == 0 && n > 0 {
return " 1%".to_string();
}
format!("{r:>3}%")
}

Expand Down

0 comments on commit 7fc2aef

Please sign in to comment.