From 7fc2aefd65485dff5d6d95559d38f97c03eed711 Mon Sep 17 00:00:00 2001 From: gram Date: Sun, 4 Aug 2024 20:50:47 +0200 Subject: [PATCH] don't show as 0% a non-zero ratio --- src/monitor.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/monitor.rs b/src/monitor.rs index 6443404..b5f4b96 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -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}%") }