We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc33dd2 commit 5892463Copy full SHA for 5892463
library/core/src/iter/traits/peekable.rs
@@ -11,7 +11,10 @@ pub trait PeekableIterator: Iterator {
11
12
/// Returns the `next()` element if the given predicate holds true.
13
fn next_if(&mut self, func: impl FnOnce(&Self::Item) -> bool) -> Option<Self::Item> {
14
- self.peek_with(|x| if func(x) { self.next() } else { None })
+ match self.peek_map(func) {
15
+ Some(true) => self.next(),
16
+ _ => None,
17
+ }
18
}
19
20
/// Moves forward and return the `next()` item if it is equal to the expected value.
0 commit comments