Skip to content

Commit

Permalink
doc: provide an actual equivalent to filter_map
Browse files Browse the repository at this point in the history
  • Loading branch information
tshepang committed Jul 22, 2017
1 parent a1f180b commit fc90064
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/libcore/iter/iterator.rs
Expand Up @@ -637,16 +637,15 @@ pub trait Iterator {
/// let a = ["1", "2", "lol"];
///
/// let mut iter = a.iter()
/// .map(|s| s.parse().ok())
/// .filter(|s| s.is_some());
/// .map(|s| s.parse())
/// .filter(|s| s.is_ok())
/// .map(|s| s.unwrap());
///
/// assert_eq!(iter.next(), Some(Some(1)));
/// assert_eq!(iter.next(), Some(Some(2)));
/// assert_eq!(iter.next(), Some(1));
/// assert_eq!(iter.next(), Some(2));
/// assert_eq!(iter.next(), None);
/// ```
///
/// There's an extra layer of [`Some`] in there.
///
/// [`Option<T>`]: ../../std/option/enum.Option.html
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
/// [`None`]: ../../std/option/enum.Option.html#variant.None
Expand Down

0 comments on commit fc90064

Please sign in to comment.