diff --git a/src/libcore/option.rs b/src/libcore/option.rs index dd60e8797a948..beed2075d0494 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -93,16 +93,12 @@ //! let msg = Some("howdy"); //! //! // Take a reference to the contained string -//! match msg { -//! Some(ref m) => println!("{}", *m), -//! None => (), +//! if let Some(ref m) = msg { +//! println!("{}", *m); //! } //! //! // Remove the contained string, destroying the Option -//! let unwrapped_msg = match msg { -//! Some(m) => m, -//! None => "default message", -//! }; +//! let unwrapped_msg = msg.unwrap_or("default message"); //! ``` //! //! Initialize a result to `None` before a loop: