diff options
author | Akshay <[email protected]> | 2020-02-10 17:14:27 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-02-10 17:14:27 +0000 |
commit | 10e2c495f0b9f1570ad94cf7caf3deaab510fcd2 (patch) | |
tree | 10db8a2b38dec3d8759604cadfdb12022f49eba2 /src | |
parent | 1dc25e3f2ec309bcb530457ebabb9a90877b4178 (diff) |
fix bug with empty countview entries
Diffstat (limited to 'src')
-rw-r--r-- | src/habit.rs | 6 |
1 files changed, 4 insertions, 2 deletions
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<bool> { | |||
50 | impl Habit<u32> { | 50 | impl Habit<u32> { |
51 | pub fn increment(&mut self, date: NaiveDate) { | 51 | pub fn increment(&mut self, date: NaiveDate) { |
52 | if let Some(v) = self.stats.get_mut(&date) { | 52 | if let Some(v) = self.stats.get_mut(&date) { |
53 | *v += 1 | 53 | *v += 1; |
54 | } else { | ||
55 | self.insert_entry(date, 1); | ||
54 | } | 56 | } |
55 | } | 57 | } |
56 | pub fn decrement(&mut self, date: NaiveDate) { | 58 | pub fn decrement(&mut self, date: NaiveDate) { |
57 | if let Some(v) = self.stats.get_mut(&date) { | 59 | if let Some(v) = self.stats.get_mut(&date) { |
58 | if *v >= 1 { | 60 | if *v > 0 { |
59 | *v -= 1; | 61 | *v -= 1; |
60 | } else { | 62 | } else { |
61 | *v = 0; | 63 | *v = 0; |