diff options
Diffstat (limited to 'src/habit/prelude.rs')
-rw-r--r-- | src/habit/prelude.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/habit/prelude.rs b/src/habit/prelude.rs index b8b2bb2..19b00a7 100644 --- a/src/habit/prelude.rs +++ b/src/habit/prelude.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | use serde::{Deserialize, Serialize}; | 1 | use serde::{Deserialize, Serialize}; |
2 | use std::default; | ||
3 | use std::fmt; | ||
2 | 4 | ||
3 | pub enum TrackEvent { | 5 | pub enum TrackEvent { |
4 | Increment, | 6 | Increment, |
@@ -13,12 +15,23 @@ pub enum ViewMode { | |||
13 | Year, | 15 | Year, |
14 | } | 16 | } |
15 | 17 | ||
16 | impl std::default::Default for ViewMode { | 18 | impl default::Default for ViewMode { |
17 | fn default() -> Self { | 19 | fn default() -> Self { |
18 | ViewMode::Day | 20 | ViewMode::Day |
19 | } | 21 | } |
20 | } | 22 | } |
21 | 23 | ||
24 | impl fmt::Display for ViewMode { | ||
25 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
26 | match self { | ||
27 | ViewMode::Day => write!(f, "DAY"), | ||
28 | ViewMode::Week => write!(f, "WEEK"), | ||
29 | ViewMode::Month => write!(f, "MONTH"), | ||
30 | ViewMode::Year => write!(f, "YEAR"), | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | |||
22 | pub fn default_auto() -> bool { | 35 | pub fn default_auto() -> bool { |
23 | false | 36 | false |
24 | } | 37 | } |