diff --git a/libimagdiary/src/diaryid.rs b/libimagdiary/src/diaryid.rs index 5549ac17..2cbdce56 100644 --- a/libimagdiary/src/diaryid.rs +++ b/libimagdiary/src/diaryid.rs @@ -205,10 +205,10 @@ impl FromStoreId for DiaryId { debug!("Year = {:?}", year); debug!("Name = {:?}", name); - let day = if day.is_none() { return None; } else { day.unwrap() }; - let month = if month.is_none() { return None; } else { month.unwrap() }; - let year = if year.is_none() { return None; } else { year.unwrap() }; - let name = if name.is_none() { return None; } else { name.unwrap() }; + let day = match day { None => return None, Some(day) => day }; + let month = match month { None => return None, Some(month) => month }; + let year = match year { None => return None, Some(year) => year }; + let name = match name { None => return None, Some(name) => name }; Some(DiaryId::new(name, year, month, day, hour, minute)) } diff --git a/libimagdiary/src/iter.rs b/libimagdiary/src/iter.rs index 1b2b16e5..5146e5a7 100644 --- a/libimagdiary/src/iter.rs +++ b/libimagdiary/src/iter.rs @@ -71,21 +71,21 @@ impl<'a> Iterator for DiaryEntryIterator<'a> { fn next(&mut self) -> Option>> { loop { - let next = self.iter.next(); + let next = match self.iter.next() { + Some(s) => s, + None => return None, + }; debug!("Next element: {:?}", next); - if next.is_none() { - return None; - } - let next = next.unwrap(); if next.is_in_diary(self.name) { debug!("Seems to be in diary: {:?}", next); - let id = DiaryId::from_storeid(&next); - if id.is_none() { - debug!("Couldn't parse {:?} into DiaryId", next); - continue; - } - let id = id.unwrap(); + let id = match DiaryId::from_storeid(&next) { + Some(i) => i, + None => { + debug!("Couldn't parse {:?} into DiaryId", next); + continue; + } + }; debug!("Success parsing id = {:?}", id); let y = match self.year { None => true, Some(y) => y == id.year() };