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 bf0193c commit dc33dd2Copy full SHA for dc33dd2
library/core/src/iter/traits/peekable.rs
@@ -11,7 +11,7 @@ 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_map(func).and_then(|_| self.next())
+ self.peek_with(|x| if func(x) { self.next() } else { None })
15
}
16
17
/// Moves forward and return the `next()` item if it is equal to the expected value.
0 commit comments