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.
InterleaveShortest::fold
1 parent 7f5f00d commit 98344adCopy full SHA for 98344ad
src/adaptors/mod.rs
@@ -195,6 +195,34 @@ where
195
};
196
(lower, upper)
197
}
198
+
199
+ fn fold<B, F>(self, mut init: B, mut f: F) -> B
200
+ where
201
+ F: FnMut(B, Self::Item) -> B,
202
+ {
203
+ let Self {
204
+ mut it0,
205
+ mut it1,
206
+ phase,
207
+ } = self;
208
+ if phase {
209
+ match it1.next() {
210
+ Some(y) => init = f(init, y),
211
+ None => return init,
212
+ }
213
214
+ let res = it0.try_fold(init, |mut acc, x| {
215
+ acc = f(acc, x);
216
217
+ Some(y) => Ok(f(acc, y)),
218
+ None => Err(acc),
219
220
+ });
221
+ match res {
222
+ Ok(val) => val,
223
+ Err(val) => val,
224
225
226
227
228
impl<I, J> FusedIterator for InterleaveShortest<I, J>
0 commit comments