Skip to content

Commit eebfcb8

Browse files
authored
Auto merge of #34540 - jupp0r:patch-1, r=steveklabnik
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.
2 parents 5e858f3 + 8f3e498 commit eebfcb8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/result.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@
175175
//! }
176176
//!
177177
//! fn write_info(info: &Info) -> io::Result<()> {
178-
//! let mut file = try!(File::create("my_best_friends.txt"));
179178
//! // Early return on error
179+
//! let mut file = match File::create("my_best_friends.txt") {
180+
//! Err(e) => return Err(e),
181+
//! Ok(f) => f,
182+
//! };
180183
//! if let Err(e) = file.write_all(format!("name: {}\n", info.name).as_bytes()) {
181184
//! return Err(e)
182185
//! }

0 commit comments

Comments
 (0)