Skip to content

Commit

Permalink
Auto merge of #32390 - japaric:untry, r=pnkfelix
Browse files Browse the repository at this point in the history
convert 99.9% of `try!`s to `?`s

The first commit is an automated conversion using the [untry] tool and the following command:

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

at the root of the Rust repo.

[untry]: https://github.com/japaric/untry

cc @rust-lang/lang @alexcrichton @brson
  • Loading branch information
bors committed Mar 23, 2016
2 parents 21ee2d8 + 4d78cbe commit 0022e65
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
#![cfg_attr(not(stage0), deny(warnings))]

#![feature(str_escape)]
#![feature(question_mark)]

use self::LabelText::*;

Expand Down Expand Up @@ -662,7 +663,7 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G,
{
fn writeln<W: Write>(w: &mut W, arg: &[&str]) -> io::Result<()> {
for &s in arg {
try!(w.write_all(s.as_bytes()));
w.write_all(s.as_bytes())?;
}
write!(w, "\n")
}
Expand All @@ -671,9 +672,9 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G,
w.write_all(b" ")
}

try!(writeln(w, &["digraph ", g.graph_id().as_slice(), " {"]));
writeln(w, &["digraph ", g.graph_id().as_slice(), " {"])?;
for n in g.nodes().iter() {
try!(indent(w));
indent(w)?;
let id = g.node_id(n);

let escaped = &g.node_label(n).to_dot_string();
Expand Down Expand Up @@ -702,12 +703,12 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G,
}

text.push(";");
try!(writeln(w, &text));
writeln(w, &text)?;
}

for e in g.edges().iter() {
let escaped_label = &g.edge_label(e).to_dot_string();
try!(indent(w));
indent(w)?;
let source = g.source(e);
let target = g.target(e);
let source_id = g.node_id(&source);
Expand All @@ -729,7 +730,7 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G,
}

text.push(";");
try!(writeln(w, &text));
writeln(w, &text)?;
}

writeln(w, &["}"])
Expand Down Expand Up @@ -959,7 +960,7 @@ mod tests {
let mut writer = Vec::new();
render(&g, &mut writer).unwrap();
let mut s = String::new();
try!(Read::read_to_string(&mut &*writer, &mut s));
Read::read_to_string(&mut &*writer, &mut s)?;
Ok(s)
}

Expand Down

0 comments on commit 0022e65

Please sign in to comment.