[No-auto] lib/domain/habit: Fix Clippy warnings
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
2ac2a86c7a
commit
6307b80027
1 changed files with 11 additions and 11 deletions
|
@ -90,7 +90,7 @@ pub trait HabitTemplate : Sized {
|
|||
fn instance_exists_for_date(&self, date: NaiveDate) -> Result<bool>;
|
||||
|
||||
/// 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<StoreId>;
|
||||
fn instance_id_for(habit_name: &str, habit_date: NaiveDate) -> Result<StoreId>;
|
||||
}
|
||||
|
||||
provide_kindflag_path!(pub IsHabitTemplate, "habit.template.is_habit_template");
|
||||
|
@ -164,7 +164,7 @@ impl HabitTemplate for Entry {
|
|||
.calculate()?
|
||||
.get_moment()
|
||||
.map(Clone::clone)
|
||||
.ok_or_else(|| Error::from(err_msg("until-date seems to have non-date value")))
|
||||
.ok_or_else(|| err_msg("until-date seems to have non-date value"))
|
||||
});
|
||||
|
||||
debug!("Until-Date is {:?}", basedate);
|
||||
|
@ -177,7 +177,7 @@ impl HabitTemplate for Entry {
|
|||
if ndt >= base {
|
||||
debug!("-> {:?} >= {:?}", ndt, base);
|
||||
if let Some(u) = until {
|
||||
if ndt > &(u?) {
|
||||
if *ndt > u? {
|
||||
return Ok(None);
|
||||
} else {
|
||||
return Ok(Some(ndt.date()));
|
||||
|
@ -249,13 +249,13 @@ impl HabitTemplate for Entry {
|
|||
Ok(false)
|
||||
}
|
||||
|
||||
fn instance_id_for(habit_name: &String, habit_date: NaiveDate) -> Result<StoreId> {
|
||||
fn instance_id_for(habit_name: &str, habit_date: NaiveDate) -> Result<StoreId> {
|
||||
instance_id_for_name_and_datestr(habit_name, &date_to_string(habit_date))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn instance_id_for_name_and_datestr(habit_name: &String, habit_date: &String) -> Result<StoreId> {
|
||||
fn instance_id_for_name_and_datestr(habit_name: &str, habit_date: &str) -> Result<StoreId> {
|
||||
crate::module_path::new_id(format!("instance/{}-{}", habit_name, habit_date))
|
||||
.context(format_err!("Failed building ID for instance: habit name = {}, habit date = {}", habit_name, habit_date))
|
||||
.map_err(Error::from)
|
||||
|
@ -318,7 +318,7 @@ pub mod builder {
|
|||
pub fn build<'a>(self, store: &'a Store) -> Result<FileLockEntry<'a>> {
|
||||
#[inline]
|
||||
fn mkerr(s: &'static str) -> Error {
|
||||
Error::from(format_err!("Habit builder missing: {}", s))
|
||||
format_err!("Habit builder missing: {}", s)
|
||||
}
|
||||
|
||||
let name = self.name
|
||||
|
@ -336,7 +336,7 @@ pub mod builder {
|
|||
if let Some(until) = self.untildate {
|
||||
debug!("Success: Until-Date present");
|
||||
if dateobj > until {
|
||||
let e = Error::from(err_msg("Habit builder logic error: until-date before start date"));
|
||||
let e = err_msg("Habit builder logic error: until-date before start date");
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
@ -348,13 +348,13 @@ pub mod builder {
|
|||
let date = date_to_string(dateobj);
|
||||
debug!("Success: Date valid");
|
||||
|
||||
let comment = self.comment.unwrap_or_else(|| String::new());
|
||||
let comment = self.comment.unwrap_or_else(String::new);
|
||||
let sid = build_habit_template_sid(&name)?;
|
||||
|
||||
debug!("Creating entry in store for: {:?}", sid);
|
||||
let mut entry = store.create(sid)?;
|
||||
|
||||
let _ = entry.set_isflag::<IsHabitTemplate>()?;
|
||||
entry.set_isflag::<IsHabitTemplate>()?;
|
||||
{
|
||||
let h = entry.get_header_mut();
|
||||
let _ = h.insert("habit.template.name", Value::String(name))?;
|
||||
|
@ -387,7 +387,7 @@ pub mod builder {
|
|||
}
|
||||
|
||||
/// Buld a StoreId for a Habit from a date object and a name of a habit
|
||||
fn build_habit_template_sid(name: &String) -> Result<StoreId> {
|
||||
fn build_habit_template_sid(name: &str) -> Result<StoreId> {
|
||||
crate::module_path::new_id(format!("template/{}", name)).map_err(From::from)
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ fn postprocess_instance<'a>(mut entry: FileLockEntry<'a>,
|
|||
-> Result<FileLockEntry<'a>>
|
||||
{
|
||||
{
|
||||
let _ = entry.set_isflag::<IsHabitInstance>()?;
|
||||
entry.set_isflag::<IsHabitInstance>()?;
|
||||
let hdr = entry.get_header_mut();
|
||||
let _ = hdr.insert("habit.instance.name", Value::String(name))?;
|
||||
let _ = hdr.insert("habit.instance.date", Value::String(date))?;
|
||||
|
|
Loading…
Reference in a new issue