summaryrefslogtreecommitdiffstats
path: root/src/interactive/app/bytevis.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/interactive/app/bytevis.rs')
-rw-r--r--src/interactive/app/bytevis.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/interactive/app/bytevis.rs b/src/interactive/app/bytevis.rs
index b27da6d..70c7714 100644
--- a/src/interactive/app/bytevis.rs
+++ b/src/interactive/app/bytevis.rs
@@ -43,6 +43,11 @@ impl fmt::Display for DisplayByteVisualization {
use ByteVisualization::*;
let Self { format, percentage } = self;
+ let percentage = if percentage.is_nan() {
+ 0.0
+ } else {
+ *percentage
+ };
const BAR_SIZE: usize = 10;
match format {
Percentage => Self::make_percentage(f, percentage),
@@ -58,7 +63,7 @@ impl fmt::Display for DisplayByteVisualization {
}
impl DisplayByteVisualization {
- fn make_bar(f: &mut fmt::Formatter, percentage: &f32, length: usize) -> Result<(), fmt::Error> {
+ fn make_bar(f: &mut fmt::Formatter, percentage: f32, length: usize) -> Result<(), fmt::Error> {
let block_length = (length as f32 * percentage).round() as usize;
for _ in 0..block_length {
f.write_str(tui::symbols::block::FULL)?;
@@ -68,7 +73,7 @@ impl DisplayByteVisualization {
}
Ok(())
}
- fn make_percentage(f: &mut fmt::Formatter, percentage: &f32) -> Result<(), fmt::Error> {
+ fn make_percentage(f: &mut fmt::Formatter, percentage: f32) -> Result<(), fmt::Error> {
write!(f, " {:>5.02}% ", percentage * 100.0)
}
}