Skip to content

Commit

Permalink
Rollup merge of rust-lang#76302 - jyn514:peekable-2, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Address review comments on `Peekable::next_if`

r? @pickfire
See rust-lang#72310 (review) for context.
  • Loading branch information
matklad authored Sep 4, 2020
2 parents 1242599 + 8c93125 commit b018ccf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/core/src/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,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`.
Expand Down Expand Up @@ -1812,7 +1812,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.
Expand All @@ -1827,10 +1827,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)
}
Expand Down

0 comments on commit b018ccf

Please sign in to comment.