diff options
| author | Tshepang Lekhonkhobe <tshepang@gmail.com> | 2017-07-22 23:22:01 +0200 |
|---|---|---|
| committer | Tshepang Lekhonkhobe <tshepang@gmail.com> | 2017-07-22 23:22:01 +0200 |
| commit | fc900645462bb4189af603fc810b050b2ce4619b (patch) | |
| tree | 98ec37d1969d9d94e4f96b39945bd185ac00df06 /src/libcore | |
| parent | a1f180bde3fedc67db04e595a29c9cb4e03f7eaf (diff) | |
| download | rust-fc900645462bb4189af603fc810b050b2ce4619b.tar.gz rust-fc900645462bb4189af603fc810b050b2ce4619b.zip | |
doc: provide an actual equivalent to filter_map
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter/iterator.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index d9887094fef..1685dba3c5a 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<T>`]: ../../std/option/enum.Option.html /// [`Some`]: ../../std/option/enum.Option.html#variant.Some /// [`None`]: ../../std/option/enum.Option.html#variant.None |
