Auto merge of #43416 - tshepang:extra-layer, r=alexcrichton

doc: provide an actual equivalent to filter_map
This commit is contained in:
bors 2017-07-23 13:04:12 +00:00
commit 6270257f4e

View File

@ -637,16 +637,15 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P> where
/// 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