From 862e1897f0a880ad98c1c514906a4056e326dbe8 Mon Sep 17 00:00:00 2001 From: Niklas Elsbrock Date: Tue, 9 Aug 2022 21:51:49 +0200 Subject: [PATCH] implement `Clone` and `Debug` on `Accumulate` --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 7360758..d69a23e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,12 +8,26 @@ /// /// See [`IterAccumulate::accumulate()`] for more information. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone)] pub struct Accumulate { iter: I, acc: B, f: F, } +impl fmt::Debug for Accumulate +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 Accumulate { fn new(iter: I, acc: B, f: F) -> Accumulate { Accumulate { iter, acc, f }