Skip to content

Commit cd6bd87

Browse files
Philippe-Cholethellow554phimuemue
committed
Itertools::find_position: use find
`find` usually rely on `try_fold` so this change should improve performance for iterators specializing `find/try_fold`. Co-Authored-By: Marcel Hellwig <[email protected]> Co-Authored-By: phimuemue <[email protected]>
1 parent c5a1b16 commit cd6bd87

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1910,12 +1910,7 @@ pub trait Itertools: Iterator {
19101910
where
19111911
P: FnMut(&Self::Item) -> bool,
19121912
{
1913-
for (index, elt) in self.enumerate() {
1914-
if pred(&elt) {
1915-
return Some((index, elt));
1916-
}
1917-
}
1918-
None
1913+
self.enumerate().find(|(_, elt)| pred(elt))
19191914
}
19201915
/// Find the value of the first element satisfying a predicate or return the last element, if any.
19211916
///

0 commit comments

Comments
 (0)