diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/habit.rs | 6 | ||||
-rw-r--r-- | src/views/bitview.rs | 4 | ||||
-rw-r--r-- | src/views/countview.rs | 3 |
3 files changed, 4 insertions, 9 deletions
diff --git a/src/habit.rs b/src/habit.rs index 967e425..6445545 100644 --- a/src/habit.rs +++ b/src/habit.rs | |||
@@ -1,8 +1,9 @@ | |||
1 | use std::collections::HashMap; | 1 | use std::collections::HashMap; |
2 | 2 | ||
3 | use chrono::NaiveDate; | 3 | use chrono::NaiveDate; |
4 | use serde::Serialize; | ||
4 | 5 | ||
5 | #[derive(Debug)] | 6 | #[derive(Serialize, Debug)] |
6 | pub struct Habit<T> { | 7 | pub struct Habit<T> { |
7 | name: String, | 8 | name: String, |
8 | stats: HashMap<NaiveDate, T>, | 9 | stats: HashMap<NaiveDate, T>, |
@@ -20,15 +21,12 @@ where | |||
20 | goal, | 21 | goal, |
21 | }; | 22 | }; |
22 | } | 23 | } |
23 | |||
24 | pub fn get_name(&self) -> String { | 24 | pub fn get_name(&self) -> String { |
25 | return self.name.to_owned(); | 25 | return self.name.to_owned(); |
26 | } | 26 | } |
27 | |||
28 | pub fn get_by_date(&self, date: NaiveDate) -> Option<&T> { | 27 | pub fn get_by_date(&self, date: NaiveDate) -> Option<&T> { |
29 | self.stats.get(&date) | 28 | self.stats.get(&date) |
30 | } | 29 | } |
31 | |||
32 | pub fn insert_entry(&mut self, date: NaiveDate, val: T) { | 30 | pub fn insert_entry(&mut self, date: NaiveDate, val: T) { |
33 | *self.stats.entry(date).or_insert(val) = val; | 31 | *self.stats.entry(date).or_insert(val) = val; |
34 | } | 32 | } |
diff --git a/src/views/bitview.rs b/src/views/bitview.rs index 16b3ad8..b31b050 100644 --- a/src/views/bitview.rs +++ b/src/views/bitview.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | use cursive::direction::Direction; | 1 | use cursive::direction::Direction; |
2 | use cursive::event::{Event, EventResult, Key}; | 2 | use cursive::event::{Event, EventResult, Key}; |
3 | use cursive::theme::{BaseColor, Color, Effect, Style}; | 3 | use cursive::theme::{BaseColor, Color, Style}; |
4 | use cursive::utils::markup::StyledString; | ||
5 | use cursive::view::View; | 4 | use cursive::view::View; |
6 | use cursive::{Printer, Vec2}; | 5 | use cursive::{Printer, Vec2}; |
7 | 6 | ||
@@ -46,7 +45,6 @@ impl View for BitView { | |||
46 | let true_style = Style::from(Color::Dark(BaseColor::Cyan)); | 45 | let true_style = Style::from(Color::Dark(BaseColor::Cyan)); |
47 | let false_style = Style::from(Color::Dark(BaseColor::Magenta)); | 46 | let false_style = Style::from(Color::Dark(BaseColor::Magenta)); |
48 | let future_style = Style::from(Color::Light(BaseColor::Black)); | 47 | let future_style = Style::from(Color::Light(BaseColor::Black)); |
49 | let today_style = Style::from(Color::Dark(BaseColor::White)); | ||
50 | 48 | ||
51 | for i in 1..=31 { | 49 | for i in 1..=31 { |
52 | let day = NaiveDate::from_ymd_opt(year, month, i); | 50 | let day = NaiveDate::from_ymd_opt(year, month, i); |
diff --git a/src/views/countview.rs b/src/views/countview.rs index 1e8855a..d906acb 100644 --- a/src/views/countview.rs +++ b/src/views/countview.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | use cursive::direction::Direction; | 1 | use cursive::direction::Direction; |
2 | use cursive::event::{Event, EventResult, Key}; | 2 | use cursive::event::{Event, EventResult, Key}; |
3 | use cursive::theme::{BaseColor, Color, Effect, Style}; | 3 | use cursive::theme::{BaseColor, Color, Style}; |
4 | use cursive::utils::markup::StyledString; | ||
5 | use cursive::view::View; | 4 | use cursive::view::View; |
6 | use cursive::{Printer, Vec2}; | 5 | use cursive::{Printer, Vec2}; |
7 | 6 | ||