Skip to content

Commit e9707bc

Browse files
committed
Implement FlattenOk::rfold
1 parent 10fb9d1 commit e9707bc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/flatten_ok.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ where
141141
}
142142
}
143143
}
144+
145+
fn rfold<B, F>(self, init: B, mut f: F) -> B
146+
where
147+
Self: Sized,
148+
F: FnMut(B, Self::Item) -> B,
149+
{
150+
self.iter.rfold(init, |acc, x| match x {
151+
Ok(it) => it.into_iter().rfold(acc, |a, o| f(a, Ok(o))),
152+
Err(e) => f(acc, Err(e)),
153+
})
154+
}
144155
}
145156

146157
impl<I, T, E> Clone for FlattenOk<I, T, E>

0 commit comments

Comments
 (0)