Address review comments on Peekable::next_if

This commit is contained in:
Joshua Nelson 2020-09-03 18:03:33 -04:00
parent 08deb863bd
commit 8c93125c17

View File

@ -1628,7 +1628,7 @@ impl<I: Iterator> Peekable<I> {
self.peeked.get_or_insert_with(|| iter.next()).as_ref()
}
/// Consume the next value of this iterator if a condition is true.
/// Consume and return the next value of this iterator if a condition is true.
///
/// If `func` returns `true` for the next value of this iterator, consume and return it.
/// Otherwise, return `None`.
@ -1668,7 +1668,7 @@ impl<I: Iterator> Peekable<I> {
}
}
/// Consume the next item if it is equal to `expected`.
/// Consume and return the next item if it is equal to `expected`.
///
/// # Example
/// Consume a number if it's equal to 0.
@ -1683,10 +1683,10 @@ impl<I: Iterator> Peekable<I> {
/// assert_eq!(iter.next(), Some(1));
/// ```
#[unstable(feature = "peekable_next_if", issue = "72480")]
pub fn next_if_eq<R>(&mut self, expected: &R) -> Option<I::Item>
pub fn next_if_eq<T>(&mut self, expected: &T) -> Option<I::Item>
where
R: ?Sized,
I::Item: PartialEq<R>,
T: ?Sized,
I::Item: PartialEq<T>,
{
self.next_if(|next| next == expected)
}