Replace matching with function chaining

This commit is contained in:
Matthias Beyer 2018-01-04 20:26:42 +01:00
parent c1ff2b14f0
commit dbd9a2faaf

View file

@ -219,11 +219,10 @@ impl HabitTemplate for Entry {
} }
fn habit_until_date(&self) -> Result<Option<String>> { fn habit_until_date(&self) -> Result<Option<String>> {
match self.get_header().read("habit.template.until")? { self.get_header()
Some(&Value::String(ref s)) => Ok(Some(s.clone())), .read("habit.template.until")?
Some(_) => Err(HEK::HeaderTypeError("habit.template.until", "String").into()), .map(|v| v.as_str().map(String::from))
None => Ok(None), .ok_or(HEK::HeaderTypeError("habit.template.until", "String").into())
}
} }
fn instance_id_for(habit_name: &String, habit_date: &NaiveDate) -> Result<StoreId> { fn instance_id_for(habit_name: &String, habit_date: &NaiveDate) -> Result<StoreId> {