diff options
Diffstat (limited to 'src/habit.rs')
-rw-r--r-- | src/habit.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/habit.rs b/src/habit.rs index 3716183..45eeefa 100644 --- a/src/habit.rs +++ b/src/habit.rs | |||
@@ -23,7 +23,7 @@ impl fmt::Display for CustomBool { | |||
23 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 23 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
24 | write!( | 24 | write!( |
25 | f, | 25 | f, |
26 | "{}", | 26 | "{:^3}", |
27 | if self.0 { | 27 | if self.0 { |
28 | CONFIGURATION.true_chr | 28 | CONFIGURATION.true_chr |
29 | } else { | 29 | } else { |
@@ -53,7 +53,7 @@ pub trait Habit { | |||
53 | fn modify(&mut self, date: NaiveDate, event: TrackEvent); | 53 | fn modify(&mut self, date: NaiveDate, event: TrackEvent); |
54 | } | 54 | } |
55 | 55 | ||
56 | pub trait HabitWrapper { | 56 | pub trait HabitWrapper: erased_serde::Serialize { |
57 | fn remaining(&self, date: NaiveDate) -> u32; | 57 | fn remaining(&self, date: NaiveDate) -> u32; |
58 | fn total(&self) -> u32; | 58 | fn total(&self) -> u32; |
59 | fn modify(&mut self, date: NaiveDate, event: TrackEvent); | 59 | fn modify(&mut self, date: NaiveDate, event: TrackEvent); |
@@ -63,9 +63,13 @@ pub trait HabitWrapper { | |||
63 | fn take_focus(&mut self, _: Direction) -> bool; | 63 | fn take_focus(&mut self, _: Direction) -> bool; |
64 | } | 64 | } |
65 | 65 | ||
66 | use erased_serde::serialize_trait_object; | ||
67 | serialize_trait_object!(HabitWrapper); | ||
68 | |||
66 | impl<T> HabitWrapper for T | 69 | impl<T> HabitWrapper for T |
67 | where | 70 | where |
68 | T: Habit + ShadowView, | 71 | T: Habit + ShadowView, |
72 | T: Serialize, | ||
69 | T::HabitType: std::fmt::Display, | 73 | T::HabitType: std::fmt::Display, |
70 | { | 74 | { |
71 | fn remaining(&self, date: NaiveDate) -> u32 { | 75 | fn remaining(&self, date: NaiveDate) -> u32 { |