From 852e5dc3a9a92761d019aaad1f1f36649610d815 Mon Sep 17 00:00:00 2001 From: nc Date: Sun, 19 Jul 2020 19:50:53 -0400 Subject: fix divide by zero for #5 --- src/views.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/views.rs b/src/views.rs index e11b844..24c8a4d 100644 --- a/src/views.rs +++ b/src/views.rs @@ -81,8 +81,8 @@ where let remaining = week.iter().map(|&i| self.remaining(i)).sum::(); let completions = weekly_goal - remaining; let full = CONFIGURATION.view_width - 8; - let bars_to_fill = (completions * full as u32) / weekly_goal; - let percentage = (completions as f64 * 100.) / weekly_goal as f64; + let bars_to_fill = if weekly_goal > 0 {(completions * full as u32) / weekly_goal} else {0}; + let percentage = if weekly_goal > 0 {(completions as f64 * 100.) / weekly_goal as f64} else {0.0}; printer.with_style(future_style, |p| { p.print((4, line_nr), &"─".repeat(full)); }); -- cgit v1.2.3