From fc900645462bb4189af603fc810b050b2ce4619b Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sat, 22 Jul 2017 23:22:01 +0200 Subject: [PATCH] doc: provide an actual equivalent to filter_map --- src/libcore/iter/iterator.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index d9887094fefb2..1685dba3c5a64 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -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`]: ../../std/option/enum.Option.html /// [`Some`]: ../../std/option/enum.Option.html#variant.Some /// [`None`]: ../../std/option/enum.Option.html#variant.None