Skip to content

Commit e964d71

Browse files
committed
slightly change the Iterator::map_while docs
1 parent 605bc1b commit e964d71

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/libcore/iter/traits/iterator.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ pub trait Iterator {
10801080
/// let iter = a.iter().map_while(|x| u32::try_from(*x).ok());
10811081
/// let vec = iter.collect::<Vec<_>>();
10821082
///
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`)
1083+
/// // We have more elements which could fit in u32 (4, 5), but `map_while` returned `None` for `-3`
1084+
/// // (as the `predicate` returned `None`) and `collect` stops at the first `None` entcountered.
10851085
/// assert_eq!(vec, vec![0, 1, 2]);
10861086
/// ```
10871087
///
@@ -1110,18 +1110,8 @@ pub trait Iterator {
11101110
/// The `-3` is no longer there, because it was consumed in order to see if
11111111
/// the iteration should stop, but wasn't placed back into the iterator.
11121112
///
1113-
/// Note that unlike [`take_while`] this iterator is **not** fused:
1114-
///
1115-
/// ```
1116-
/// #![feature(iter_map_while)]
1117-
/// use std::convert::identity;
1118-
///
1119-
/// let mut iter = vec![Some(0), None, Some(1)].into_iter().map_while(identity);
1120-
/// assert_eq!(iter.next(), Some(0));
1121-
/// assert_eq!(iter.next(), None);
1122-
/// assert_eq!(iter.next(), Some(1));
1123-
/// ```
1124-
///
1113+
/// Note that unlike [`take_while`] this iterator is **not** fused.
1114+
/// It is also not specified what this iterator returns after the first` None` is returned.
11251115
/// If you need fused iterator, use [`fuse`].
11261116
///
11271117
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some

0 commit comments

Comments
 (0)