implement Clone and Debug on Accumulate

This commit is contained in:
2022-08-09 22:11:55 +02:00
parent 50118996f2
commit 862e1897f0
+14
View File
@@ -8,12 +8,26 @@
/// ///
/// See [`IterAccumulate::accumulate()`] for more information. /// See [`IterAccumulate::accumulate()`] for more information.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[derive(Clone)]
pub struct Accumulate<I, B, F> { pub struct Accumulate<I, B, F> {
iter: I, iter: I,
acc: B, acc: B,
f: F, f: F,
} }
impl<I, B, F> fmt::Debug for Accumulate<I, B, F>
where
I: fmt::Debug,
B: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Accumulate")
.field("iter", &self.iter)
.field("acc", &self.acc)
.finish()
}
}
impl<I, B, F> Accumulate<I, B, F> { impl<I, B, F> Accumulate<I, B, F> {
fn new(iter: I, acc: B, f: F) -> Accumulate<I, B, F> { fn new(iter: I, acc: B, f: F) -> Accumulate<I, B, F> {
Accumulate { iter, acc, f } Accumulate { iter, acc, f }