Skip to content

Commit b2dfb7c

Browse files
committed
Rollup merge of #32464 - GuillaumeGomez:patch-6, r=steveklabnik
Improve some Option code example Part of #29366. r? @steveklabnik
2 parents bce02a2 + b922d1a commit b2dfb7c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/libcore/option.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,12 @@
9393
//! let msg = Some("howdy");
9494
//!
9595
//! // Take a reference to the contained string
96-
//! match msg {
97-
//! Some(ref m) => println!("{}", *m),
98-
//! None => (),
96+
//! if let Some(ref m) = msg {
97+
//! println!("{}", *m);
9998
//! }
10099
//!
101100
//! // Remove the contained string, destroying the Option
102-
//! let unwrapped_msg = match msg {
103-
//! Some(m) => m,
104-
//! None => "default message",
105-
//! };
101+
//! let unwrapped_msg = msg.unwrap_or("default message");
106102
//! ```
107103
//!
108104
//! Initialize a result to `None` before a loop:

0 commit comments

Comments
 (0)