Skip to content

Commit

Permalink
fix(ci): Clippy Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Nov 28, 2024
1 parent 0d890fd commit 950b0be
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl BackoffStorage {
pub(crate) fn is_backoff_with_slack(&self, topic: &TopicHash, peer: &PeerId) -> bool {
self.backoffs
.get(topic)
.map_or(false, |m| m.contains_key(peer))
.is_some_and(|m| m.contains_key(peer))
}

pub(crate) fn get_backoff_time(&self, topic: &TopicHash, peer: &PeerId) -> Option<Instant> {
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ where
let self_published = !self.config.allow_self_origin()
&& if let Some(own_id) = self.publish_config.get_own_id() {
own_id != propagation_source
&& raw_message.source.as_ref().map_or(false, |s| s == own_id)
&& raw_message.source.as_ref().is_some_and(|s| s == own_id)
} else {
self.published_message_ids.contains(msg_id)
};
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl PutRecordJob {
T: RecordStore,
{
if self.inner.check_ready(cx, now) {
let publish = self.next_publish.map_or(false, |t_pub| now >= t_pub);
let publish = self.next_publish.is_some_and(|t_pub| now >= t_pub);
let records = store
.records()
.filter_map(|r| {
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/kbucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ where

/// Returns true if the bucket has a pending node.
pub fn has_pending(&self) -> bool {
self.bucket.pending().map_or(false, |n| !n.is_ready())
self.bucket.pending().is_some_and(|n| !n.is_ready())
}

/// Tests whether the given distance falls into this bucket.
pub fn contains(&self, d: &Distance) -> bool {
BucketIndex::new(d).map_or(false, |i| i == self.index)
BucketIndex::new(d).is_some_and(|i| i == self.index)
}

/// Generates a random distance that falls into this bucket.
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/kbucket/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ where
// Adjust `first_connected_pos` accordingly.
match status {
NodeStatus::Connected => {
if self.first_connected_pos.map_or(false, |p| p == pos.0)
if self.first_connected_pos.is_some_and(|p| p == pos.0)
&& pos.0 == self.nodes.len()
{
// It was the last connected node.
Expand All @@ -398,7 +398,7 @@ where

/// Returns the status of the node at the given position.
pub(crate) fn status(&self, pos: Position) -> NodeStatus {
if self.first_connected_pos.map_or(false, |i| pos.0 >= i) {
if self.first_connected_pos.is_some_and(|i| pos.0 >= i) {
NodeStatus::Connected
} else {
NodeStatus::Disconnected
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Record {

/// Checks whether the record is expired w.r.t. the given `Instant`.
pub fn is_expired(&self, now: Instant) -> bool {
self.expires.map_or(false, |t| now >= t)
self.expires.is_some_and(|t| now >= t)
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ impl ProviderRecord {

/// Checks whether the provider record is expired w.r.t. the given `Instant`.
pub fn is_expired(&self, now: Instant) -> bool {
self.expires.map_or(false, |t| now >= t)
self.expires.is_some_and(|t| now >= t)
}
}

Expand Down
2 changes: 1 addition & 1 deletion swarm/src/connection/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct PendingConnection {

impl PendingConnection {
fn is_for_same_remote_as(&self, other: PeerId) -> bool {
self.peer_id.map_or(false, |peer| peer == other)
self.peer_id == Some(other)
}

/// Aborts the connection attempt, closing the connection.
Expand Down
2 changes: 1 addition & 1 deletion transports/noise/src/io/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
.id_remote_pubkey
.ok_or_else(|| Error::AuthenticationFailed)?;

let is_valid_signature = self.dh_remote_pubkey_sig.as_ref().map_or(false, |s| {
let is_valid_signature = self.dh_remote_pubkey_sig.as_ref().is_some_and(|s| {
id_pk.verify(&[STATIC_KEY_DOMAIN.as_bytes(), pubkey.as_ref()].concat(), s)
});

Expand Down
2 changes: 2 additions & 0 deletions transports/websocket-websys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

//! Libp2p websocket transports built on [web-sys](https://rustwasm.github.io/wasm-bindgen/web-sys/index.html).

#![allow(unexpected_cfgs)]

mod web_context;

use bytes::BytesMut;
Expand Down
2 changes: 2 additions & 0 deletions transports/webtransport-websys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Libp2p WebTransport built on [web-sys](https://rustwasm.github.io/wasm-bindgen/web-sys/index.html)

#![allow(unexpected_cfgs)]

mod bindings;
mod connection;
mod endpoint;
Expand Down
2 changes: 2 additions & 0 deletions wasm-tests/webtransport-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unexpected_cfgs)]

use futures::channel::oneshot;
use futures::{AsyncReadExt, AsyncWriteExt};
use getrandom::getrandom;
Expand Down

0 comments on commit 950b0be

Please sign in to comment.