Rollup merge of #102263 - GuillaumeGomez:iterator-rposition-example, r=thomcc

Clarify Iterator::rposition code example

Fixes #101095.

r? `@thomcc`
This commit is contained in:
fee1-dead 2022-09-26 09:27:37 +08:00 committed by GitHub
commit beb224084d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2906,14 +2906,14 @@ fn check<T>(
/// 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")]