Skip to content

Commit

Permalink
Rollup merge of rust-lang#32464 - GuillaumeGomez:patch-6, r=steveklabnik
Browse files Browse the repository at this point in the history
Improve some Option code example

Part of rust-lang#29366.

r? @steveklabnik
  • Loading branch information
steveklabnik committed Mar 24, 2016
2 parents bce02a2 + b922d1a commit b2dfb7c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b2dfb7c

Please sign in to comment.