From 97e21b80e92b28873bca2e55401d9342ecc6567f Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 9 Jan 2025 19:21:21 +0100 Subject: [PATCH] chore(code): Fix clippy warnings on Rust 1.84 --- code/crates/core-votekeeper/src/keeper.rs | 2 +- code/crates/discovery/src/controller.rs | 11 ++++++----- code/crates/discovery/src/handlers/close.rs | 6 ++---- code/crates/discovery/src/handlers/identify.rs | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/code/crates/core-votekeeper/src/keeper.rs b/code/crates/core-votekeeper/src/keeper.rs index 622893a6b..3d1a3e4c9 100644 --- a/code/crates/core-votekeeper/src/keeper.rs +++ b/code/crates/core-votekeeper/src/keeper.rs @@ -268,7 +268,7 @@ where vote_type: VoteType, threshold: Threshold>, ) -> bool { - self.per_round.get(round).map_or(false, |per_round| { + self.per_round.get(round).is_some_and(|per_round| { per_round.votes.is_threshold_met( vote_type, threshold, diff --git a/code/crates/discovery/src/controller.rs b/code/crates/discovery/src/controller.rs index 66fb1e075..75fd93a62 100644 --- a/code/crates/discovery/src/controller.rs +++ b/code/crates/discovery/src/controller.rs @@ -140,11 +140,12 @@ impl Controller { } pub(crate) fn dial_is_done_on(&self, connection_data: &ConnectionData) -> bool { - connection_data.peer_id().map_or(false, |peer_id| { - self.dial.is_done_on(&PeerData::PeerId(peer_id)) - }) || self - .dial - .is_done_on(&PeerData::Multiaddr(connection_data.multiaddr())) + connection_data + .peer_id() + .is_some_and(|peer_id| self.dial.is_done_on(&PeerData::PeerId(peer_id))) + || self + .dial + .is_done_on(&PeerData::Multiaddr(connection_data.multiaddr())) } pub(crate) fn dial_add_peer_id_to_connection_data( diff --git a/code/crates/discovery/src/handlers/close.rs b/code/crates/discovery/src/handlers/close.rs index c460ee6af..06b636c0b 100644 --- a/code/crates/discovery/src/handlers/close.rs +++ b/code/crates/discovery/src/handlers/close.rs @@ -34,7 +34,7 @@ where if self .active_connections .get(&peer_id) - .map_or(false, |connections| connections.contains(&connection_id)) + .is_some_and(|connections| connections.contains(&connection_id)) { if swarm.close_connection(connection_id) { info!("Closing connection {connection_id} to peer {peer_id}"); @@ -70,9 +70,7 @@ where if self .outbound_connections .get(&peer_id) - .map_or(false, |out_conn| { - out_conn.connection_id == Some(connection_id) - }) + .is_some_and(|out_conn| out_conn.connection_id == Some(connection_id)) { warn!("Outbound connection {connection_id} to peer {peer_id} closed"); diff --git a/code/crates/discovery/src/handlers/identify.rs b/code/crates/discovery/src/handlers/identify.rs index cc4dfb3b0..156951de2 100644 --- a/code/crates/discovery/src/handlers/identify.rs +++ b/code/crates/discovery/src/handlers/identify.rs @@ -25,7 +25,7 @@ where if self .active_connections .get(&peer_id) - .map_or(false, |connections| connections.contains(&connection_id)) + .is_some_and(|connections| connections.contains(&connection_id)) { return; } @@ -76,7 +76,7 @@ where if self .outbound_connections .get(&peer_id) - .map_or(false, |out_conn| out_conn.connection_id.is_none()) + .is_some_and(|out_conn| out_conn.connection_id.is_none()) { // This case happens when the peer was selected to be part of the outbound connections // but no connection was established yet. No need to trigger a connect request, it