1
Fork 0

try! -> ?

Automated conversion using the untry tool [1] and the following command:

```
$ find -name '*.rs' -type f | xargs untry
```

at the root of the Rust repo.

[1]: https://github.com/japaric/untry
This commit is contained in:
Jorge Aparicio 2016-03-22 22:01:37 -05:00
parent 0dcc413e42
commit 0f02309e4b
132 changed files with 3755 additions and 3770 deletions

View file

@ -46,10 +46,10 @@ pub fn log_enabled() -> bool {
// These output functions should now be used everywhere to ensure consistency.
pub fn output(w: &mut Write, idx: isize, addr: *mut libc::c_void,
s: Option<&[u8]>) -> io::Result<()> {
try!(write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH));
write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH)?;
match s.and_then(|s| str::from_utf8(s).ok()) {
Some(string) => try!(demangle(w, string)),
None => try!(write!(w, "<unknown>")),
Some(string) => demangle(w, string)?,
None => write!(w, "<unknown>")?,
}
w.write_all(&['\n' as u8])
}
@ -59,9 +59,9 @@ pub fn output_fileline(w: &mut Write, file: &[u8], line: libc::c_int,
more: bool) -> io::Result<()> {
let file = str::from_utf8(file).unwrap_or("<unknown>");
// prior line: " ##: {:2$} - func"
try!(write!(w, " {:3$}at {}:{}", "", file, line, HEX_WIDTH));
write!(w, " {:3$}at {}:{}", "", file, line, HEX_WIDTH)?;
if more {
try!(write!(w, " <... and possibly more>"));
write!(w, " <... and possibly more>")?;
}
w.write_all(&['\n' as u8])
}
@ -121,12 +121,12 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> {
// Alright, let's do this.
if !valid {
try!(writer.write_all(s.as_bytes()));
writer.write_all(s.as_bytes())?;
} else {
let mut first = true;
while !inner.is_empty() {
if !first {
try!(writer.write_all(b"::"));
writer.write_all(b"::")?;
} else {
first = false;
}
@ -177,7 +177,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> {
None => rest.len(),
Some(i) => i,
};
try!(writer.write_all(rest[..idx].as_bytes()));
writer.write_all(rest[..idx].as_bytes())?;
rest = &rest[idx..];
}
}