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!("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))
}

View file

@ -71,21 +71,21 @@ impl<'a> Iterator for DiaryEntryIterator<'a> {
fn next(&mut self) -> Option<Result<DiaryEntry<'a>>> {
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() };