about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/option.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 607e16887a8..8871e1fa840 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -659,6 +659,16 @@ impl<T> Option<T> {
 impl<'a, T: Clone> Option<&'a T> {
     /// Maps an `Option<&T>` to an `Option<T>` by cloning the contents of the
     /// option.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let x = 12;
+    /// let opt_x = Some(&x);
+    /// assert_eq!(opt_x, Some(&12));
+    /// let cloned = opt_x.cloned();
+    /// assert_eq!(cloned, Some(12));
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn cloned(self) -> Option<T> {
         self.map(|t| t.clone())