Skip to content

Commit 99517be

Browse files
committed
implement Default and Clone manually
1 parent 9ca1b18 commit 99517be

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

block-buffer/src/lib.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub type EagerBuffer<B> = BlockBuffer<B, Eager>;
4242
pub type LazyBuffer<B> = BlockBuffer<B, Lazy>;
4343

4444
/// Buffer for block processing of data.
45-
#[derive(Default, Clone, Debug)]
45+
#[derive(Debug)]
4646
pub struct BlockBuffer<BlockSize, Kind>
4747
where
4848
BlockSize: ArrayLength<u8> + IsLess<U256>,
@@ -54,6 +54,36 @@ where
5454
_pd: PhantomData<Kind>,
5555
}
5656

57+
impl<BlockSize, Kind> Default for BlockBuffer<BlockSize, Kind>
58+
where
59+
BlockSize: ArrayLength<u8> + IsLess<U256>,
60+
Le<BlockSize, U256>: NonZero,
61+
Kind: BufferKind,
62+
{
63+
fn default() -> Self {
64+
Self {
65+
buffer: Default::default(),
66+
pos: 0,
67+
_pd: PhantomData,
68+
}
69+
}
70+
}
71+
72+
impl<BlockSize, Kind> Clone for BlockBuffer<BlockSize, Kind>
73+
where
74+
BlockSize: ArrayLength<u8> + IsLess<U256>,
75+
Le<BlockSize, U256>: NonZero,
76+
Kind: BufferKind,
77+
{
78+
fn clone(&self) -> Self {
79+
Self {
80+
buffer: self.buffer.clone(),
81+
pos: self.pos.clone(),
82+
_pd: PhantomData,
83+
}
84+
}
85+
}
86+
5787
impl<BlockSize, Kind> BlockBuffer<BlockSize, Kind>
5888
where
5989
BlockSize: ArrayLength<u8> + IsLess<U256>,

0 commit comments

Comments
 (0)