From 8c139f2d3b266b432b6c061f5088508b12d04004 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sat, 17 Dec 2022 13:01:45 +1100 Subject: [PATCH] chore: apply suggestions from beta clippy (#3251) --- core/src/upgrade/apply.rs | 6 +++--- protocols/gossipsub/src/behaviour.rs | 4 ++-- swarm/tests/swarm_derive.rs | 16 +++++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/src/upgrade/apply.rs b/core/src/upgrade/apply.rs index 8f0bcdabc55..76a48baed04 100644 --- a/core/src/upgrade/apply.rs +++ b/core/src/upgrade/apply.rs @@ -284,7 +284,7 @@ impl fmt::Display for DisplayProtocolName { if (b' '..=b'~').contains(byte) { f.write_char(char::from(*byte))?; } else { - write!(f, "<{:02X}>", byte)?; + write!(f, "<{byte:02X}>")?; } } Ok(()) @@ -302,9 +302,9 @@ mod tests { assert_eq!( DisplayProtocolName((0u8..=255).collect::>()).to_string(), (0..32) - .map(|c| format!("<{:02X}>", c)) + .map(|c| format!("<{c:02X}>")) .chain((32..127).map(|c| format!("{}", char::from_u32(c).unwrap()))) - .chain((127..256).map(|c| format!("<{:02X}>", c))) + .chain((127..256).map(|c| format!("<{c:02X}>"))) .collect::() ); } diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index c361fc4fdbc..5d1b69ec0fb 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -3678,10 +3678,10 @@ impl fmt::Debug for PublishConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { PublishConfig::Signing { author, .. } => { - f.write_fmt(format_args!("PublishConfig::Signing({})", author)) + f.write_fmt(format_args!("PublishConfig::Signing({author})")) } PublishConfig::Author(author) => { - f.write_fmt(format_args!("PublishConfig::Author({})", author)) + f.write_fmt(format_args!("PublishConfig::Author({author})")) } PublishConfig::RandomAuthor => f.write_fmt(format_args!("PublishConfig::RandomAuthor")), PublishConfig::Anonymous => f.write_fmt(format_args!("PublishConfig::Anonymous")), diff --git a/swarm/tests/swarm_derive.rs b/swarm/tests/swarm_derive.rs index 84fb3bf4683..08f04081297 100644 --- a/swarm/tests/swarm_derive.rs +++ b/swarm/tests/swarm_derive.rs @@ -256,21 +256,19 @@ fn custom_event_emit_event_through_poll() { } #[allow(dead_code, unreachable_code, clippy::diverging_sub_expression)] - fn bar() { + async fn bar() { require_net_behaviour::(); let mut _swarm: libp2p_swarm::Swarm = unimplemented!(); // check that the event is bubbled up all the way to swarm - let _ = async { - loop { - match _swarm.select_next_some().await { - SwarmEvent::Behaviour(BehaviourOutEvent::Ping(_)) => break, - SwarmEvent::Behaviour(BehaviourOutEvent::Identify(_)) => break, - _ => {} - } + loop { + match _swarm.select_next_some().await { + SwarmEvent::Behaviour(BehaviourOutEvent::Ping(_)) => break, + SwarmEvent::Behaviour(BehaviourOutEvent::Identify(_)) => break, + _ => {} } - }; + } } }