Replace uses of try!() macro with "?" operator
This commit is contained in:
parent
9308c05057
commit
e758a28c9e
2 changed files with 8 additions and 8 deletions
|
@ -209,7 +209,7 @@ impl FromStoreId for DiaryId {
|
||||||
|
|
||||||
let mut cmps = s.components().rev();
|
let mut cmps = s.components().rev();
|
||||||
|
|
||||||
let (hour, minute) = try!(next_component(&mut cmps).and_then(|time| {
|
let (hour, minute) = next_component(&mut cmps).and_then(|time| {
|
||||||
let mut time = time.split(":");
|
let mut time = time.split(":");
|
||||||
let hour = time.next().and_then(|s| FromStr::from_str(s).ok());
|
let hour = time.next().and_then(|s| FromStr::from_str(s).ok());
|
||||||
let minute = time.next()
|
let minute = time.next()
|
||||||
|
@ -223,7 +223,7 @@ impl FromStoreId for DiaryId {
|
||||||
(Some(h), Some(m)) => Ok((h, m)),
|
(Some(h), Some(m)) => Ok((h, m)),
|
||||||
_ => return Err(DE::from_kind(DEK::IdParseError)),
|
_ => return Err(DE::from_kind(DEK::IdParseError)),
|
||||||
}
|
}
|
||||||
}));
|
})?;
|
||||||
|
|
||||||
let day: Result<u32,_> = next_component(&mut cmps)
|
let day: Result<u32,_> = next_component(&mut cmps)
|
||||||
.and_then(|s| s.parse::<u32>()
|
.and_then(|s| s.parse::<u32>()
|
||||||
|
@ -244,10 +244,10 @@ impl FromStoreId for DiaryId {
|
||||||
debug!("Year = {:?}", year);
|
debug!("Year = {:?}", year);
|
||||||
debug!("Name = {:?}", name);
|
debug!("Name = {:?}", name);
|
||||||
|
|
||||||
let day = try!(day);
|
let day = day?;
|
||||||
let month = try!(month);
|
let month = month?;
|
||||||
let year = try!(year);
|
let year = year?;
|
||||||
let name = try!(name);
|
let name = name?;
|
||||||
|
|
||||||
Ok(DiaryId::new(name, year, month, day, hour, minute))
|
Ok(DiaryId::new(name, year, month, day, hour, minute))
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,10 +54,10 @@ impl DiaryViewer {
|
||||||
Ok(id) => println!("{} :\n", id),
|
Ok(id) => println!("{} :\n", id),
|
||||||
Err(e) => trace_error(&e),
|
Err(e) => trace_error(&e),
|
||||||
}
|
}
|
||||||
let _ = try!(self.0
|
let _ = self.0
|
||||||
.view_entry(&entry)
|
.view_entry(&entry)
|
||||||
.chain_err(|| DEK::ViewError)
|
.chain_err(|| DEK::ViewError)
|
||||||
.chain_err(|| DEK::IOError));
|
.chain_err(|| DEK::IOError)?;
|
||||||
println!("\n---\n");
|
println!("\n---\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue