@@ -1036,9 +1036,6 @@ pub trait Iterator {
1036
1036
/// closure on each element of the iterator, and yield elements
1037
1037
/// while it returns [`Some(_)`][`Some`].
1038
1038
///
1039
- /// After [`None`] is returned, `map_while()`'s job is over, and the
1040
- /// rest of the elements are ignored.
1041
- ///
1042
1039
/// # Examples
1043
1040
///
1044
1041
/// Basic usage:
@@ -1078,15 +1075,14 @@ pub trait Iterator {
1078
1075
/// #![feature(iter_map_while)]
1079
1076
/// use std::convert::TryFrom;
1080
1077
///
1081
- /// let a = [0, - 1, 1 , -2 ];
1078
+ /// let a = [0, 1, 2 , -3, 4, 5, -6 ];
1082
1079
///
1083
- /// let mut iter = a.iter().map_while(|x| u32::try_from(*x).ok());
1080
+ /// let iter = a.iter().map_while(|x| u32::try_from(*x).ok());
1081
+ /// let vec = iter.collect::<Vec<_>>();
1084
1082
///
1085
- /// assert_eq!(iter.next(), Some(0u32));
1086
- ///
1087
- /// // We have more elements that are fit in u32, but since we already
1088
- /// // got a None, map_while() isn't used any more
1089
- /// assert_eq!(iter.next(), None);
1083
+ /// // We have more elements which could fit in u32 (4, 5), but `map_while`
1084
+ /// // has stopped on the first `None` from predicate (when working with `-3`)
1085
+ /// assert_eq!(vec, vec![0, 1, 2]);
1090
1086
/// ```
1091
1087
///
1092
1088
/// Because `map_while()` needs to look at the value in order to see if it
0 commit comments