From 10e2c495f0b9f1570ad94cf7caf3deaab510fcd2 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 10 Feb 2020 22:44:27 +0530 Subject: fix bug with empty countview entries --- src/habit.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/habit.rs b/src/habit.rs index 88e1cb6..967e425 100644 --- a/src/habit.rs +++ b/src/habit.rs @@ -50,12 +50,14 @@ impl Habit { impl Habit { pub fn increment(&mut self, date: NaiveDate) { if let Some(v) = self.stats.get_mut(&date) { - *v += 1 + *v += 1; + } else { + self.insert_entry(date, 1); } } pub fn decrement(&mut self, date: NaiveDate) { if let Some(v) = self.stats.get_mut(&date) { - if *v >= 1 { + if *v > 0 { *v -= 1; } else { *v = 0; -- cgit v1.2.3