Skip to content

Commit 11c63cd

Browse files
committed
Merge pull request #21103 from nagisa/result-typo
[r+] Fix a typo and use if-let instead of match in std::result docs Reviewed-by: steveklabnik
2 parents 6ad1f55 + 1217007 commit 11c63cd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/libcore/result.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
//! drop(file);
120120
//! ```
121121
//!
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
123123
//! warning (by default, controlled by the `unused_must_use` lint).
124124
//!
125125
//! You might instead, if you don't want to handle the error, simply
@@ -178,13 +178,11 @@
178178
//! fn write_info(info: &Info) -> Result<(), IoError> {
179179
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
180180
//! // 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)
184183
//! }
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)
188186
//! }
189187
//! return file.write_line(format!("rating: {}", info.rating).as_slice());
190188
//! }

0 commit comments

Comments
 (0)