mirror of
https://github.com/nelsbrock/iter_accumulate.git
synced 2026-08-14 22:16:48 +02:00
implement Clone and Debug on Accumulate
This commit is contained in:
+14
@@ -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 }
|
||||||
|
|||||||
Reference in New Issue
Block a user