Skip to content

Commit dc33dd2

Browse files
committed
Update next_if to use the bool
1 parent bf0193c commit dc33dd2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/iter/traits/peekable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub trait PeekableIterator: Iterator {
1111

1212
/// Returns the `next()` element if the given predicate holds true.
1313
fn next_if(&mut self, func: impl FnOnce(&Self::Item) -> bool) -> Option<Self::Item> {
14-
self.peek_map(func).and_then(|_| self.next())
14+
self.peek_with(|x| if func(x) { self.next() } else { None })
1515
}
1616

1717
/// Moves forward and return the `next()` item if it is equal to the expected value.

0 commit comments

Comments
 (0)