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.
FilterMapOk::next
find_map
1 parent b19eb9e commit b2b44aaCopy full SHA for b2b44aa
src/adaptors/mod.rs
@@ -982,17 +982,11 @@ where
982
type Item = Result<U, E>;
983
984
fn next(&mut self) -> Option<Self::Item> {
985
- loop {
986
- match self.iter.next() {
987
- Some(Ok(v)) => {
988
- if let Some(v) = (self.f)(v) {
989
- return Some(Ok(v));
990
- }
991
992
- Some(Err(e)) => return Some(Err(e)),
993
- None => return None,
994
995
+ let f = &mut self.f;
+ self.iter.find_map(|res| match res {
+ Ok(t) => f(t).map(Ok),
+ Err(e) => Some(Err(e)),
+ })
996
}
997
998
fn size_hint(&self) -> (usize, Option<usize>) {
0 commit comments