File tree 1 file changed +4
-2
lines changed
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> {
943
943
// Transforming contained values
944
944
/////////////////////////////////////////////////////////////////////////
945
945
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`) .
947
947
///
948
948
/// # Examples
949
949
///
@@ -955,8 +955,10 @@ impl<T> Option<T> {
955
955
/// let maybe_some_string = Some(String::from("Hello, World!"));
956
956
/// // `Option::map` takes self *by value*, consuming `maybe_some_string`
957
957
/// let maybe_some_len = maybe_some_string.map(|s| s.len());
958
- ///
959
958
/// assert_eq!(maybe_some_len, Some(13));
959
+ ///
960
+ /// let x: Option<&str> = None;
961
+ /// assert_eq!(x.map(|s| s.len()), None);
960
962
/// ```
961
963
#[ inline]
962
964
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments