Rollup merge of #130053 - glowcoil:next_if-docs, r=jhpratt

fix doc comments for Peekable::next_if(_eq)

Fix references to a nonexistent `consume` function in the doc comments for `Peekable::next_if` and `Peekable::next_if_eq`.
This commit is contained in:
Stuart Cook 2024-09-14 20:22:40 +10:00 committed by GitHub
commit c992f97cb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -269,7 +269,7 @@ pub fn peek_mut(&mut self) -> Option<&mut I::Item> {
/// let mut iter = (0..5).peekable();
/// // The first item of the iterator is 0; consume it.
/// assert_eq!(iter.next_if(|&x| x == 0), Some(0));
/// // The next item returned is now 1, so `consume` will return `false`.
/// // The next item returned is now 1, so `next_if` will return `None`.
/// assert_eq!(iter.next_if(|&x| x == 0), None);
/// // `next_if` saves the value of the next item if it was not equal to `expected`.
/// assert_eq!(iter.next(), Some(1));
@ -304,7 +304,7 @@ pub fn next_if(&mut self, func: impl FnOnce(&I::Item) -> bool) -> Option<I::Item
/// let mut iter = (0..5).peekable();
/// // The first item of the iterator is 0; consume it.
/// assert_eq!(iter.next_if_eq(&0), Some(0));
/// // The next item returned is now 1, so `consume` will return `false`.
/// // The next item returned is now 1, so `next_if` will return `None`.
/// assert_eq!(iter.next_if_eq(&0), None);
/// // `next_if_eq` saves the value of the next item if it was not equal to `expected`.
/// assert_eq!(iter.next(), Some(1));