Merge pull request #623 from matthiasbeyer/libimagdiary/remove-unwraps

Libimagdiary/remove unwraps
This commit is contained in:
Matthias Beyer 2016-08-05 13:19:35 +02:00 committed by GitHub
commit 0d7f7a3ac1
2 changed files with 15 additions and 15 deletions

View file

@ -205,10 +205,10 @@ impl FromStoreId for DiaryId {
debug!("Year = {:?}", year); debug!("Year = {:?}", year);
debug!("Name = {:?}", name); debug!("Name = {:?}", name);
let day = if day.is_none() { return None; } else { day.unwrap() }; let day = match day { None => return None, Some(day) => day };
let month = if month.is_none() { return None; } else { month.unwrap() }; let month = match month { None => return None, Some(month) => month };
let year = if year.is_none() { return None; } else { year.unwrap() }; let year = match year { None => return None, Some(year) => year };
let name = if name.is_none() { return None; } else { name.unwrap() }; let name = match name { None => return None, Some(name) => name };
Some(DiaryId::new(name, year, month, day, hour, minute)) Some(DiaryId::new(name, year, month, day, hour, minute))
} }

View file

@ -71,21 +71,21 @@ impl<'a> Iterator for DiaryEntryIterator<'a> {
fn next(&mut self) -> Option<Result<DiaryEntry<'a>>> { fn next(&mut self) -> Option<Result<DiaryEntry<'a>>> {
loop { loop {
let next = self.iter.next(); let next = match self.iter.next() {
Some(s) => s,
None => return None,
};
debug!("Next element: {:?}", next); debug!("Next element: {:?}", next);
if next.is_none() {
return None;
}
let next = next.unwrap();
if next.is_in_diary(self.name) { if next.is_in_diary(self.name) {
debug!("Seems to be in diary: {:?}", next); debug!("Seems to be in diary: {:?}", next);
let id = DiaryId::from_storeid(&next); let id = match DiaryId::from_storeid(&next) {
if id.is_none() { Some(i) => i,
debug!("Couldn't parse {:?} into DiaryId", next); None => {
continue; debug!("Couldn't parse {:?} into DiaryId", next);
} continue;
let id = id.unwrap(); }
};
debug!("Success parsing id = {:?}", id); debug!("Success parsing id = {:?}", id);
let y = match self.year { None => true, Some(y) => y == id.year() }; let y = match self.year { None => true, Some(y) => y == id.year() };