about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-03-24 13:24:39 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-03-24 13:24:39 +0100
commitb922d1a40577e14df324ff36f69ad0f0e3857af7 (patch)
tree3e3adc0a17fa7a02d67e176a0d158d67e876eb3f /src/libcore
parent43843d06ea9598722b3af9019e8d0059c052382d (diff)
Improve some Option code example
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/option.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index dd60e8797a9..beed2075d04 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: