diff options
| author | fee1-dead <ent3rm4n@gmail.com> | 2022-09-26 09:27:37 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-26 09:27:37 +0800 |
| commit | beb224084da8a5ee261775be03f25da3832ad890 (patch) | |
| tree | 680e43a8f6d4321a8eace5f1989e6afd8fc23021 | |
| parent | c80727738287fbeb97ca08a58d479f94bb170035 (diff) | |
| parent | a20672c91910461ff1a9e89118631029297ddd37 (diff) | |
| download | rust-beb224084da8a5ee261775be03f25da3832ad890.tar.gz rust-beb224084da8a5ee261775be03f25da3832ad890.zip | |
Rollup merge of #102263 - GuillaumeGomez:iterator-rposition-example, r=thomcc
Clarify Iterator::rposition code example Fixes #101095. r? `@thomcc`
| -rw-r--r-- | library/core/src/iter/traits/iterator.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 45be7bdd8db..e26920b25cc 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -2906,14 +2906,14 @@ pub trait Iterator { /// Stopping at the first `true`: /// /// ``` - /// let a = [1, 2, 3]; + /// let a = [-1, 2, 3, 4]; /// /// let mut iter = a.iter(); /// - /// assert_eq!(iter.rposition(|&x| x == 2), Some(1)); + /// assert_eq!(iter.rposition(|&x| x >= 2), Some(3)); /// /// // we can still use `iter`, as there are more elements. - /// assert_eq!(iter.next(), Some(&1)); + /// assert_eq!(iter.next(), Some(&-1)); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] |
