diff options
| author | Jupp Müller <jupp0r@gmail.com> | 2016-06-29 01:13:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-29 01:13:03 +0200 |
| commit | 8f3e4989a5253f3baac79b8ee27a47aec53c0159 (patch) | |
| tree | 7cc2e2f65fdf98f133bb6be10cc67ecf2ec55c7f | |
| parent | 366de839ae9794411419c5b579c829e18adde613 (diff) | |
| download | rust-8f3e4989a5253f3baac79b8ee27a47aec53c0159.tar.gz rust-8f3e4989a5253f3baac79b8ee27a47aec53c0159.zip | |
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.
| -rw-r--r-- | src/libcore/result.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 4d9f042fdde..94c6c636ce8 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) //! } |
