Skip to content

Commit

Permalink
Improve code example for try!
Browse files Browse the repository at this point in the history
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
jupp0r authored Jun 28, 2016
1 parent 366de83 commit 8f3e498
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 8f3e498

Please sign in to comment.