Skip to content

Commit aeaa05b

Browse files
committed
remove unnecessary Clone
1 parent a510f35 commit aeaa05b

3 files changed

Lines changed: 3 additions & 37 deletions

File tree

ipld/hamt/src/hamt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ where
363363
/// map.set(4, 2).unwrap();
364364
///
365365
/// let mut total = 0;
366-
/// map.for_each(|_, v| {
366+
/// map.for_each(|_, v: &u64| {
367367
/// total += v;
368368
/// Ok(())
369369
/// }).unwrap();
@@ -398,16 +398,15 @@ where
398398
/// map.set(4, 2).unwrap();
399399
///
400400
/// let mut total = 0;
401-
/// map.for_each_cacheless(|_, v| {
401+
/// map.for_each_cacheless(|_, v: &u64| {
402402
/// total += v;
403403
/// Ok(())
404404
/// }).unwrap();
405405
/// assert_eq!(total, 3);
406406
/// ```
407407
pub fn for_each_cacheless<F>(&self, mut f: F) -> Result<(), Error>
408408
where
409-
K: Clone,
410-
V: DeserializeOwned + Clone,
409+
V: DeserializeOwned,
411410
F: FnMut(&K, &V) -> anyhow::Result<()>,
412411
{
413412
self.root

ipld/hamt/src/node.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ pub(crate) struct Node<K, V, H, Ver = version::V3> {
2929
hash: PhantomData<H>,
3030
}
3131

32-
impl<K, V, H, Ver> Clone for Node<K, V, H, Ver>
33-
where
34-
K: Clone,
35-
V: Clone,
36-
{
37-
fn clone(&self) -> Self {
38-
Self {
39-
bitfield: self.bitfield,
40-
pointers: self.pointers.clone(),
41-
hash: Default::default(),
42-
}
43-
}
44-
}
45-
4632
impl<K: PartialEq, V: PartialEq, H, Ver> PartialEq for Node<K, V, H, Ver> {
4733
fn eq(&self, other: &Self) -> bool {
4834
(self.bitfield == other.bitfield) && (self.pointers == other.pointers)
@@ -230,8 +216,6 @@ where
230216
where
231217
F: FnMut(&K, &V) -> anyhow::Result<()>,
232218
S: Blockstore,
233-
K: Clone,
234-
V: Clone,
235219
{
236220
enum IterItem<'a, T> {
237221
Borrowed(&'a T),

ipld/hamt/src/pointer.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,6 @@ pub(crate) enum Pointer<K, V, H, Ver = version::V3> {
4646
Dirty(Box<Node<K, V, H, Ver>>),
4747
}
4848

49-
impl<K, V, H, Ver> Clone for Pointer<K, V, H, Ver>
50-
where
51-
K: Clone,
52-
V: Clone,
53-
{
54-
fn clone(&self) -> Self {
55-
match self {
56-
Self::Values(v) => Self::Values(v.clone()),
57-
Self::Link { cid, cache: _ } => Self::Link {
58-
cid: *cid,
59-
cache: Default::default(),
60-
},
61-
Self::Dirty(n) => Self::Dirty(n.clone()),
62-
}
63-
}
64-
}
65-
6649
impl<K: PartialEq, V: PartialEq, H, Ver> PartialEq for Pointer<K, V, H, Ver> {
6750
fn eq(&self, other: &Self) -> bool {
6851
match (self, other) {

0 commit comments

Comments
 (0)