From 036357bc3c6227ac747c89cc82c29ef6a940ccbe Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 11 Feb 2020 21:14:20 +0530 Subject: serialize dates, remove cruft --- src/habit.rs | 6 ++---- src/views/bitview.rs | 4 +--- src/views/countview.rs | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') 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 @@ use std::collections::HashMap; use chrono::NaiveDate; +use serde::Serialize; -#[derive(Debug)] +#[derive(Serialize, Debug)] pub struct Habit { name: String, stats: HashMap, @@ -20,15 +21,12 @@ where goal, }; } - pub fn get_name(&self) -> String { return self.name.to_owned(); } - pub fn get_by_date(&self, date: NaiveDate) -> Option<&T> { self.stats.get(&date) } - pub fn insert_entry(&mut self, date: NaiveDate, val: T) { *self.stats.entry(date).or_insert(val) = val; } 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 @@ use cursive::direction::Direction; use cursive::event::{Event, EventResult, Key}; -use cursive::theme::{BaseColor, Color, Effect, Style}; -use cursive::utils::markup::StyledString; +use cursive::theme::{BaseColor, Color, Style}; use cursive::view::View; use cursive::{Printer, Vec2}; @@ -46,7 +45,6 @@ impl View for BitView { let true_style = Style::from(Color::Dark(BaseColor::Cyan)); let false_style = Style::from(Color::Dark(BaseColor::Magenta)); let future_style = Style::from(Color::Light(BaseColor::Black)); - let today_style = Style::from(Color::Dark(BaseColor::White)); for i in 1..=31 { 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 @@ use cursive::direction::Direction; use cursive::event::{Event, EventResult, Key}; -use cursive::theme::{BaseColor, Color, Effect, Style}; -use cursive::utils::markup::StyledString; +use cursive::theme::{BaseColor, Color, Style}; use cursive::view::View; use cursive::{Printer, Vec2}; -- cgit v1.2.3