aboutsummaryrefslogtreecommitdiff
path: root/src/habit.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-03-18 06:04:41 +0000
committerAkshay <[email protected]>2020-03-18 06:04:41 +0000
commit33d053d442082547550fc9a54473e05565907f88 (patch)
treed21697ada3135dd322a80e96cb68dcfe091389f4 /src/habit.rs
parent0ed2a357ec1446dd03eba963d0e144ef3ebba25a (diff)
require new super trait, add quit callback
Diffstat (limited to 'src/habit.rs')
-rw-r--r--src/habit.rs8
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
56pub trait HabitWrapper { 56pub 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
66use erased_serde::serialize_trait_object;
67serialize_trait_object!(HabitWrapper);
68
66impl<T> HabitWrapper for T 69impl<T> HabitWrapper for T
67where 70where
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 {