*: Apply clippy suggestions (#2540)

This commit is contained in:
Max Inden
2022-02-28 10:05:17 +01:00
committed by GitHub
parent b1859464c9
commit 99855b1d10
9 changed files with 37 additions and 56 deletions

View File

@ -473,14 +473,9 @@ where
/// Lists all mesh peers for a certain topic hash.
pub fn mesh_peers(&self, topic_hash: &TopicHash) -> impl Iterator<Item = &PeerId> {
self.mesh
.get(topic_hash)
.into_iter()
.map(|x| x.iter())
.flatten()
self.mesh.get(topic_hash).into_iter().flat_map(|x| x.iter())
}
/// Lists all mesh peers for all topics.
pub fn all_mesh_peers(&self) -> impl Iterator<Item = &PeerId> {
let mut res = BTreeSet::new();
for peers in self.mesh.values() {

View File

@ -240,8 +240,7 @@ impl NetworkBehaviour for Identify {
if let Some(entry) = self.discovered_peers.get_mut(peer_id) {
for addr in failed_addresses
.into_iter()
.map(|addresses| addresses.into_iter())
.flatten()
.flat_map(|addresses| addresses.into_iter())
{
entry.remove(addr);
}

View File

@ -189,12 +189,11 @@ impl NetworkBehaviour for Relay {
.get(remote_peer_id)
.into_iter()
.flatten()
.map(
.flat_map(
|IncomingRelayReq::DialingDst {
incoming_relay_req, ..
}| incoming_relay_req.dst_peer().addrs.clone(),
)
.flatten(),
),
)
.collect()
}

View File

@ -110,8 +110,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingDstReq {
} = CircuitRelay::decode(msg)?;
match r#type
.map(circuit_relay::Type::from_i32)
.flatten()
.and_then(circuit_relay::Type::from_i32)
.ok_or(OutgoingDstReqError::ParseTypeField)?
{
circuit_relay::Type::Status => {}
@ -126,8 +125,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingDstReq {
}
match code
.map(circuit_relay::Status::from_i32)
.flatten()
.and_then(circuit_relay::Status::from_i32)
.ok_or(OutgoingDstReqError::ParseStatusField)?
{
circuit_relay::Status::Success => {}

View File

@ -120,8 +120,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingRelayReq {
} = CircuitRelay::decode(msg)?;
match r#type
.map(circuit_relay::Type::from_i32)
.flatten()
.and_then(circuit_relay::Type::from_i32)
.ok_or(OutgoingRelayReqError::ParseTypeField)?
{
circuit_relay::Type::Status => {}
@ -129,8 +128,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingRelayReq {
}
match code
.map(circuit_relay::Status::from_i32)
.flatten()
.and_then(circuit_relay::Status::from_i32)
.ok_or(OutgoingRelayReqError::ParseStatusField)?
{
circuit_relay::Status::Success => {}

View File

@ -437,8 +437,7 @@ impl NetworkBehaviour for Relay {
} else if let Some(dst_conn) = self
.reservations
.get(&inbound_circuit_req.dst())
.map(|cs| cs.iter().next())
.flatten()
.and_then(|cs| cs.iter().next())
{
// Accept circuit request if reservation present.
let circuit_id = self.circuits.insert(Circuit {