aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/habit.rs6
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> {
50impl Habit<u32> { 50impl 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;