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.
Positions::fold
1 parent b07b0ad commit e23d1cbCopy full SHA for e23d1cb
src/adaptors/mod.rs
@@ -1081,6 +1081,21 @@ where
1081
fn size_hint(&self) -> (usize, Option<usize>) {
1082
(0, self.iter.size_hint().1)
1083
}
1084
+
1085
+ fn fold<B, G>(self, init: B, mut func: G) -> B
1086
+ where
1087
+ G: FnMut(B, Self::Item) -> B,
1088
+ {
1089
+ let mut count = self.count;
1090
+ let mut f = self.f;
1091
+ self.iter.fold(init, |mut acc, val| {
1092
+ if f(val) {
1093
+ acc = func(acc, count);
1094
+ }
1095
+ count += 1;
1096
+ acc
1097
+ })
1098
1099
1100
1101
impl<I, F> DoubleEndedIterator for Positions<I, F>
0 commit comments