Skip to content

Commit 4168e02

Browse files
committed
Stop using ok().expect() in Result docs
1 parent f7a6167 commit 4168e02

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/libcore/result.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,15 @@
117117
//! warning (by default, controlled by the `unused_must_use` lint).
118118
//!
119119
//! You might instead, if you don't want to handle the error, simply
120-
//! panic, by converting to an `Option` with `ok`, then asserting
121-
//! success with `expect`. This will panic if the write fails, proving
122-
//! a marginally useful message indicating why:
120+
//! assert success with `expect`. This will panic if the
121+
//! write fails, providing a marginally useful message indicating why:
123122
//!
124123
//! ```{.no_run}
125124
//! use std::fs::File;
126125
//! use std::io::prelude::*;
127126
//!
128127
//! let mut file = File::create("valuable_data.txt").unwrap();
129-
//! file.write_all(b"important message").ok().expect("failed to write message");
128+
//! file.write_all(b"important message").expect("failed to write message");
130129
//! ```
131130
//!
132131
//! You might also simply assert success:

0 commit comments

Comments
 (0)