Use question_mark feature in libstd.

This commit is contained in:
Ahmed Charles 2016-08-27 07:33:36 -07:00
parent d73e374ddb
commit 637f1492e7
3 changed files with 4 additions and 5 deletions

View File

@ -150,7 +150,7 @@ impl<T> Packet<T> {
let timed_out = !wait_token.wait_max_until(deadline);
// Try to reset the state
if timed_out {
try!(self.abort_selection().map_err(Upgraded));
self.abort_selection().map_err(Upgraded)?;
}
} else {
wait_token.wait();

View File

@ -187,8 +187,7 @@ impl<T> Packet<T> {
if let Some(deadline) = deadline {
let timed_out = !wait_token.wait_max_until(deadline);
if timed_out {
try!(self.abort_selection(/* was_upgrade = */ false)
.map_err(Upgraded));
self.abort_selection(/* was_upgrade = */ false).map_err(Upgraded)?;
}
} else {
wait_token.wait();

View File

@ -153,11 +153,11 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> {
macro_rules! demangle {
($($pat:expr => $demangled:expr),*) => ({
$(if rest.starts_with($pat) {
try!(writer.write_all($demangled));
writer.write_all($demangled)?;
rest = &rest[$pat.len()..];
} else)*
{
try!(writer.write_all(rest.as_bytes()));
writer.write_all(rest.as_bytes())?;
break;
}