From 940750b5db494b207c0c4da0675f8b68cd1d7a6b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 12 Oct 2021 13:28:57 +0200 Subject: fix clippy on basalt code --- src/peering/basalt.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/peering') diff --git a/src/peering/basalt.rs b/src/peering/basalt.rs index abfe1e4..a53571e 100644 --- a/src/peering/basalt.rs +++ b/src/peering/basalt.rs @@ -52,6 +52,7 @@ impl Peer { fn cost(&self, seed: &Seed) -> Cost { let mut hasher = hash::State::new(); hasher.update(&seed[..]); + let hasher = hasher; let mut cost = [0u8; 40]; match self.addr { @@ -59,7 +60,7 @@ impl Peer { let v4ip = v4addr.ip().octets(); for i in 0..4 { - let mut h = hasher.clone(); + let mut h = hasher; h.update(&v4ip[..i + 1]); cost[i * 8..(i + 1) * 8].copy_from_slice(&h.finalize()[..8]); } @@ -68,7 +69,7 @@ impl Peer { let v6ip = v6addr.ip().octets(); for i in 0..4 { - let mut h = hasher.clone(); + let mut h = hasher; h.update(&v6ip[..i + 2]); cost[i * 8..(i + 1) * 8].copy_from_slice(&h.finalize()[..8]); } @@ -76,7 +77,7 @@ impl Peer { } { - let mut h5 = hasher.clone(); + let mut h5 = hasher; h5.update(&format!("{} {}", self.addr, hex::encode(self.id)).into_bytes()[..]); cost[32..40].copy_from_slice(&h5.finalize()[..8]); } @@ -115,8 +116,7 @@ impl BasaltView { fn current_peers(&self) -> HashSet { self.slots .iter() - .filter(|s| s.peer.is_some()) - .map(|s| s.peer.unwrap().clone()) + .filter_map(|s| s.peer) .collect::>() } fn current_peers_vec(&self) -> Vec { @@ -131,7 +131,7 @@ impl BasaltView { .filter(|(_i, s)| s.peer.is_some()) .map(|(i, _s)| i) .collect::>(); - if possibles.len() == 0 { + if possibles.is_empty() { vec![] } else { let mut ret = vec![]; @@ -290,7 +290,7 @@ impl Basalt { let basalt2 = basalt.clone(); netapp.add_msg_handler::(move |_from: NodeID, push_msg: PushMessage| { basalt2.handle_peer_list(&push_msg.peers[..]); - async move { () } + async move { } }); basalt -- cgit v1.2.3