File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 117
117
//! warning (by default, controlled by the `unused_must_use` lint).
118
118
//!
119
119
//! 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:
123
122
//!
124
123
//! ```{.no_run}
125
124
//! use std::fs::File;
126
125
//! use std::io::prelude::*;
127
126
//!
128
127
//! 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");
130
129
//! ```
131
130
//!
132
131
//! You might also simply assert success:
You can’t perform that action at this time.
0 commit comments