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.
RepeatN::fold
1 parent 451c72a commit 33afea5Copy full SHA for 33afea5
src/repeatn.rs
@@ -44,6 +44,22 @@ where
44
fn size_hint(&self) -> (usize, Option<usize>) {
45
(self.n, Some(self.n))
46
}
47
+
48
+ fn fold<B, F>(self, mut init: B, mut f: F) -> B
49
+ where
50
+ F: FnMut(B, Self::Item) -> B,
51
+ {
52
+ match self {
53
+ Self {
54
+ elt: Some(elt),
55
+ n: n @ 1..,
56
+ } => {
57
+ init = (1..n).map(|_| elt.clone()).fold(init, &mut f);
58
+ f(init, elt)
59
+ }
60
+ _ => init,
61
62
63
64
65
impl<A> DoubleEndedIterator for RepeatN<A>
0 commit comments