Skip to content

Commit

Permalink
Stop using ok().expect() in Result docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fhartwig committed Nov 1, 2015
1 parent f7a6167 commit 4168e02
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/libcore/result.rs
Expand Up @@ -117,16 +117,15 @@
//! warning (by default, controlled by the `unused_must_use` lint).
//!
//! You might instead, if you don't want to handle the error, simply
//! panic, by converting to an `Option` with `ok`, then asserting
//! success with `expect`. This will panic if the write fails, proving
//! a marginally useful message indicating why:
//! assert success with `expect`. This will panic if the
//! write fails, providing a marginally useful message indicating why:
//!
//! ```{.no_run}
//! use std::fs::File;
//! use std::io::prelude::*;
//!
//! let mut file = File::create("valuable_data.txt").unwrap();
//! file.write_all(b"important message").ok().expect("failed to write message");
//! file.write_all(b"important message").expect("failed to write message");
//! ```
//!
//! You might also simply assert success:
Expand Down

0 comments on commit 4168e02

Please sign in to comment.