Improve some Option code example

This commit is contained in:
Guillaume Gomez 2016-03-24 13:24:39 +01:00
parent 43843d06ea
commit b922d1a405

View File

@ -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: