diff --git a/lib/domain/libimaghabit/src/habit.rs b/lib/domain/libimaghabit/src/habit.rs index 1884eafa..8ad3adc2 100644 --- a/lib/domain/libimaghabit/src/habit.rs +++ b/lib/domain/libimaghabit/src/habit.rs @@ -55,7 +55,7 @@ pub trait HabitTemplate : Sized { /// /// It uses `Store::retrieve()` underneath. So if there is already an instance for the day /// passed, this will simply return the instance. - fn create_instance_with_date<'a>(&mut self, store: &'a Store, date: &NaiveDate) + fn create_instance_with_date<'a>(&mut self, store: &'a Store, date: NaiveDate) -> Result>; /// Shortcut for calling `Self::create_instance_with_date()` with an instance of @@ -63,7 +63,7 @@ pub trait HabitTemplate : Sized { fn create_instance_today<'a>(&mut self, store: &'a Store) -> Result>; /// Same as `HabitTemplate::create_instance_with_date()` but uses `Store::retrieve` internally. - fn retrieve_instance_with_date<'a>(&mut self, store: &'a Store, date: &NaiveDate) + fn retrieve_instance_with_date<'a>(&mut self, store: &'a Store, date: NaiveDate) -> Result>; /// Same as `HabitTemplate::create_instance_today()` but uses `Store::retrieve` internally. @@ -87,17 +87,17 @@ pub trait HabitTemplate : Sized { fn habit_comment(&self) -> Result; fn habit_until_date(&self) -> Result>; - fn instance_exists_for_date(&self, date: &NaiveDate) -> Result; + fn instance_exists_for_date(&self, date: NaiveDate) -> Result; /// Create a StoreId for a habit name and a date the habit should be instantiated for - fn instance_id_for(habit_name: &String, habit_date: &NaiveDate) -> Result; + fn instance_id_for(habit_name: &String, habit_date: NaiveDate) -> Result; } provide_kindflag_path!(pub IsHabitTemplate, "habit.template.is_habit_template"); impl HabitTemplate for Entry { - fn create_instance_with_date<'a>(&mut self, store: &'a Store, date: &NaiveDate) -> Result> { + fn create_instance_with_date<'a>(&mut self, store: &'a Store, date: NaiveDate) -> Result> { let name = self.habit_name()?; let date = date_to_string(date); let id = instance_id_for_name_and_datestr(&name, &date)?; @@ -108,10 +108,10 @@ impl HabitTemplate for Entry { } fn create_instance_today<'a>(&mut self, store: &'a Store) -> Result> { - self.create_instance_with_date(store, &Local::today().naive_local()) + self.create_instance_with_date(store, Local::today().naive_local()) } - fn retrieve_instance_with_date<'a>(&mut self, store: &'a Store, date: &NaiveDate) -> Result> { + fn retrieve_instance_with_date<'a>(&mut self, store: &'a Store, date: NaiveDate) -> Result> { let name = self.habit_name()?; let date = date_to_string(date); let id = instance_id_for_name_and_datestr(&name, &date)?; @@ -122,7 +122,7 @@ impl HabitTemplate for Entry { } fn retrieve_instance_today<'a>(&mut self, store: &'a Store) -> Result> { - self.retrieve_instance_with_date(store, &Local::today().naive_local()) + self.retrieve_instance_with_date(store, Local::today().naive_local()) } fn linked_instances(&self) -> Result { @@ -233,7 +233,7 @@ impl HabitTemplate for Entry { .map(|os| os.map(String::from)) } - fn instance_exists_for_date(&self, date: &NaiveDate) -> Result { + fn instance_exists_for_date(&self, date: NaiveDate) -> Result { let name = self.habit_name()?; let date = date_to_string(date); @@ -246,10 +246,10 @@ impl HabitTemplate for Entry { } } - return Ok(false); + Ok(false) } - fn instance_id_for(habit_name: &String, habit_date: &NaiveDate) -> Result { + fn instance_id_for(habit_name: &String, habit_date: NaiveDate) -> Result { instance_id_for_name_and_datestr(habit_name, &date_to_string(habit_date)) } @@ -345,7 +345,7 @@ pub mod builder { debug!("Kairos failed: {:?}", e); return Err(e) } - let date = date_to_string(&dateobj); + let date = date_to_string(dateobj); debug!("Success: Date valid"); let comment = self.comment.unwrap_or_else(|| String::new()); @@ -364,7 +364,7 @@ pub mod builder { } if let Some(until) = self.untildate { - let until = date_to_string(&until); + let until = date_to_string(until); entry.get_header_mut().insert("habit.template.until", Value::String(until))?; } diff --git a/lib/domain/libimaghabit/src/instance.rs b/lib/domain/libimaghabit/src/instance.rs index b5a0443b..e0541cca 100644 --- a/lib/domain/libimaghabit/src/instance.rs +++ b/lib/domain/libimaghabit/src/instance.rs @@ -45,7 +45,7 @@ pub trait HabitInstance { fn is_habit_instance(&self) -> Result; fn get_date(&self) -> Result; - fn set_date(&mut self, n: &NaiveDate) -> Result<()>; + fn set_date(&mut self, n: NaiveDate) -> Result<()>; fn get_comment(&self, store: &Store) -> Result; fn get_template_name(&self) -> Result; } @@ -63,7 +63,7 @@ impl HabitInstance for Entry { get_string_header_from_entry(self, "habit.instance.date").and_then(date_from_string) } - fn set_date(&mut self, n: &NaiveDate) -> Result<()> { + fn set_date(&mut self, n: NaiveDate) -> Result<()> { use libimagutil::date::date_to_string; // Using `set` here because when creating the entry, these headers should be made present. self.get_header_mut()