Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion library/core/src/iter/traits/double_ended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,18 @@ pub trait DoubleEndedIterator: Iterator {
/// ```
/// let a = [1, 2, 3];
///
/// assert_eq!(a.iter().rfind(|&&x| x == 2), Some(&2));
/// assert_eq!(a.into_iter().rfind(|&x| x == 2), Some(2));
/// assert_eq!(a.into_iter().rfind(|&x| x == 5), None);
/// ```
///
/// Iterating over references:
///
/// ```
/// let a = [1, 2, 3];
///
/// // `iter()` yields references i.e. `&i32` and `rfind()` takes a
/// // reference to each element.
/// assert_eq!(a.iter().rfind(|&&x| x == 2), Some(&2));
/// assert_eq!(a.iter().rfind(|&&x| x == 5), None);
/// ```
///
Expand Down
11 changes: 11 additions & 0 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,17 @@ pub trait Iterator {
/// assert_eq!(a.into_iter().find(|&x| x == 5), None);
/// ```
///
/// Iterating over references:
///
/// ```
/// let a = [1, 2, 3];
///
/// // `iter()` yields references i.e. `&i32` and `find()` takes a
/// // reference to each element.
/// assert_eq!(a.iter().find(|&&x| x == 2), Some(&2));
/// assert_eq!(a.iter().find(|&&x| x == 5), None);
/// ```
///
/// Stopping at the first `true`:
///
/// ```
Expand Down
Loading