Skip to content

Commit

Permalink
Auto merge of #34540 - jupp0r:patch-1, r=steveklabnik
Browse files Browse the repository at this point in the history
Improve code example for try!

This change improves the code example for try!,
avoiding to use try! in the example code that shows
what code constructs try! can replace.
  • Loading branch information
bors authored Jul 3, 2016
2 parents 5e858f3 + 8f3e498 commit eebfcb8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@
//! }
//!
//! fn write_info(info: &Info) -> io::Result<()> {
//! let mut file = try!(File::create("my_best_friends.txt"));
//! // Early return on error
//! let mut file = match File::create("my_best_friends.txt") {
//! Err(e) => return Err(e),
//! Ok(f) => f,
//! };
//! if let Err(e) = file.write_all(format!("name: {}\n", info.name).as_bytes()) {
//! return Err(e)
//! }
Expand Down

0 comments on commit eebfcb8

Please sign in to comment.