Skip to content

Commit 6270257

Browse files
committedJul 23, 2017
Auto merge of #43416 - tshepang:extra-layer, r=alexcrichton
doc: provide an actual equivalent to filter_map
2 parents 3cf2c04 + fc90064 commit 6270257

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
 

‎src/libcore/iter/iterator.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -637,16 +637,15 @@ pub trait Iterator {
637637
/// let a = ["1", "2", "lol"];
638638
///
639639
/// let mut iter = a.iter()
640-
/// .map(|s| s.parse().ok())
641-
/// .filter(|s| s.is_some());
640+
/// .map(|s| s.parse())
641+
/// .filter(|s| s.is_ok())
642+
/// .map(|s| s.unwrap());
642643
///
643-
/// assert_eq!(iter.next(), Some(Some(1)));
644-
/// assert_eq!(iter.next(), Some(Some(2)));
644+
/// assert_eq!(iter.next(), Some(1));
645+
/// assert_eq!(iter.next(), Some(2));
645646
/// assert_eq!(iter.next(), None);
646647
/// ```
647648
///
648-
/// There's an extra layer of [`Some`] in there.
649-
///
650649
/// [`Option<T>`]: ../../std/option/enum.Option.html
651650
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
652651
/// [`None`]: ../../std/option/enum.Option.html#variant.None

0 commit comments

Comments
 (0)
Please sign in to comment.