File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -943,7 +943,7 @@ impl<T> Option<T> {
943943 // Transforming contained values
944944 /////////////////////////////////////////////////////////////////////////
945945
946- /// Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
946+ /// Maps an `Option<T>` to `Option<U>` by applying a function to a contained value (if `Some`) or returns `None` (if `None`) .
947947 ///
948948 /// # Examples
949949 ///
@@ -955,8 +955,10 @@ impl<T> Option<T> {
955955 /// let maybe_some_string = Some(String::from("Hello, World!"));
956956 /// // `Option::map` takes self *by value*, consuming `maybe_some_string`
957957 /// let maybe_some_len = maybe_some_string.map(|s| s.len());
958- ///
959958 /// assert_eq!(maybe_some_len, Some(13));
959+ ///
960+ /// let x: Option<&str> = None;
961+ /// assert_eq!(x.map(|s| s.len()), None);
960962 /// ```
961963 #[ inline]
962964 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments