From 8f3e4989a5253f3baac79b8ee27a47aec53c0159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jupp=20M=C3=BCller?= Date: Wed, 29 Jun 2016 01:13:03 +0200 Subject: [PATCH] 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. --- src/libcore/result.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 4d9f042fdded..94c6c636ce8f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -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) //! }