File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 119
119
//! drop(file);
120
120
//! ```
121
121
//!
122
- //! If you *do* write that in Rust, the compiler will by give you a
122
+ //! If you *do* write that in Rust, the compiler will give you a
123
123
//! warning (by default, controlled by the `unused_must_use` lint).
124
124
//!
125
125
//! You might instead, if you don't want to handle the error, simply
178
178
//! fn write_info(info: &Info) -> Result<(), IoError> {
179
179
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
180
180
//! // Early return on error
181
- //! match file.write_line(format!("name: {}", info.name).as_slice()) {
182
- //! Ok(_) => (),
183
- //! Err(e) => return Err(e)
181
+ //! if let Err(e) = file.write_line(format!("name: {}", info.name).as_slice()) {
182
+ //! return Err(e)
184
183
//! }
185
- //! match file.write_line(format!("age: {}", info.age).as_slice()) {
186
- //! Ok(_) => (),
187
- //! Err(e) => return Err(e)
184
+ //! if let Err(e) = file.write_line(format!("age: {}", info.age).as_slice()) {
185
+ //! return Err(e)
188
186
//! }
189
187
//! return file.write_line(format!("rating: {}", info.rating).as_slice());
190
188
//! }
You can’t perform that action at this time.
0 commit comments