Skip to content

Commit

Permalink
chore: Apply clippy lints from Rust 1.76
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Feb 26, 2024
1 parent 42f9384 commit b79a615
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 57 deletions.
2 changes: 1 addition & 1 deletion commons/zenoh-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! [Click here for Zenoh's documentation](../zenoh/index.html)
pub use lazy_static::lazy_static;
pub mod macros;
pub use macros::*;

use std::future::{Future, Ready};

// Re-exports after moving ZError/ZResult to zenoh-result
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-keyexpr/src/key_expr/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl keyexpr {
pub unsafe fn from_slice_unchecked(s: &[u8]) -> &Self {
core::mem::transmute(s)
}
pub fn chunks(&self) -> impl Iterator<Item = &Self> + DoubleEndedIterator {
pub fn chunks(&self) -> impl DoubleEndedIterator<Item = &Self> {
self.split('/').map(|c| unsafe {
// Any chunk of a valid KE is itself a valid KE => we can safely call the unchecked constructor.
Self::from_str_unchecked(c)
Expand Down
12 changes: 6 additions & 6 deletions commons/zenoh-protocol/src/core/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Parameters {
}
}

pub fn iter(s: &str) -> impl Iterator<Item = (&str, &str)> + DoubleEndedIterator {
pub fn iter(s: &str) -> impl DoubleEndedIterator<Item = (&str, &str)> {
s.split(LIST_SEPARATOR).filter_map(|prop| {
if prop.is_empty() {
None
Expand All @@ -99,7 +99,7 @@ impl Parameters {
Self::iter(s).find(|x| x.0 == k).map(|x| x.1)
}

pub fn values<'s>(s: &'s str, k: &str) -> impl Iterator<Item = &'s str> + DoubleEndedIterator {
pub fn values<'s>(s: &'s str, k: &str) -> impl DoubleEndedIterator<Item = &'s str> {
match Self::get(s, k) {
Some(v) => v.split(VALUE_SEPARATOR),
None => {
Expand Down Expand Up @@ -277,15 +277,15 @@ impl<'a> Metadata<'a> {
self.as_str().is_empty()
}

pub fn iter(&'a self) -> impl Iterator<Item = (&'a str, &'a str)> + DoubleEndedIterator {
pub fn iter(&'a self) -> impl DoubleEndedIterator<Item = (&'a str, &'a str)> {
Parameters::iter(self.0)
}

pub fn get(&'a self, k: &str) -> Option<&'a str> {
Parameters::get(self.0, k)
}

pub fn values(&'a self, k: &str) -> impl Iterator<Item = &'a str> + DoubleEndedIterator {
pub fn values(&'a self, k: &str) -> impl DoubleEndedIterator<Item = &'a str> {
Parameters::values(self.0, k)
}
}
Expand Down Expand Up @@ -394,15 +394,15 @@ impl<'a> Config<'a> {
self.as_str().is_empty()
}

pub fn iter(&'a self) -> impl Iterator<Item = (&'a str, &'a str)> + DoubleEndedIterator {
pub fn iter(&'a self) -> impl DoubleEndedIterator<Item = (&'a str, &'a str)> {
Parameters::iter(self.0)
}

pub fn get(&'a self, k: &str) -> Option<&'a str> {
Parameters::get(self.0, k)
}

pub fn values(&'a self, k: &str) -> impl Iterator<Item = &'a str> + DoubleEndedIterator {
pub fn values(&'a self, k: &str) -> impl DoubleEndedIterator<Item = &'a str> {
Parameters::values(self.0, k)
}
}
Expand Down
8 changes: 4 additions & 4 deletions commons/zenoh-protocol/src/core/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ pub enum Bits {
}

impl Bits {
const S8: &str = "8bit";
const S16: &str = "16bit";
const S32: &str = "32bit";
const S64: &str = "64bit";
const S8: &'static str = "8bit";
const S16: &'static str = "16bit";
const S32: &'static str = "32bit";
const S64: &'static str = "64bit";

pub const fn bits(&self) -> u32 {
match self {
Expand Down
6 changes: 3 additions & 3 deletions commons/zenoh-protocol/src/core/whatami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub enum WhatAmI {
}

impl WhatAmI {
const STR_R: &str = "router";
const STR_P: &str = "peer";
const STR_C: &str = "client";
const STR_R: &'static str = "router";
const STR_P: &'static str = "peer";
const STR_C: &'static str = "client";

const U8_R: u8 = Self::Router as u8;
const U8_P: u8 = Self::Peer as u8;
Expand Down
6 changes: 2 additions & 4 deletions io/zenoh-links/zenoh-link-udp/src/multicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ impl LinkManagerMulticastUdp {
IpAddr::V6(_) => x.is_ipv6(),
})
.take(1)
.collect::<Vec<IpAddr>>()
.get(0)
.collect::<Vec<IpAddr>>().first()
.copied(),
};
}
Expand All @@ -193,8 +192,7 @@ impl LinkManagerMulticastUdp {
}
})
.take(1)
.collect::<Vec<IpAddr>>()
.get(0)
.collect::<Vec<IpAddr>>().first()
.copied();

match iface {
Expand Down
12 changes: 3 additions & 9 deletions plugins/zenoh-backend-traits/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@ impl<S: Into<String> + AsRef<str>, V: AsObject> TryFrom<(S, &V)> for PluginConfi
storages,
rest: value
.into_iter()
.filter_map(|(k, v)| {
(!["__required__", "backend_search_dirs", "volumes", "storages"]
.contains(&k.as_str()))
.then(|| (k.clone(), v.clone()))
})
.filter(|&(k, _v)| (!["__required__", "backend_search_dirs", "volumes", "storages"]
.contains(&k.as_str()))).map(|(k, v)| (k.clone(), v.clone()))
.collect(),
})
}
Expand Down Expand Up @@ -313,10 +310,7 @@ impl VolumeConfig {
required,
rest: config
.iter()
.filter_map(|(k, v)| {
(!["__path__", "__required__"].contains(&k.as_str()))
.then(|| (k.clone(), v.clone()))
})
.filter(|&(k, _v)| (!["__path__", "__required__"].contains(&k.as_str()))).map(|(k, v)| (k.clone(), v.clone()))
.collect(),
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/src/replica/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub mod storage;
pub use align_queryable::AlignQueryable;
pub use aligner::Aligner;
pub use digest::{Digest, DigestConfig, EraType, LogEntry};
pub use snapshotter::{ReplicationInfo, Snapshotter};
pub use snapshotter::{Snapshotter};
pub use storage::{ReplicationService, StorageService};

const ERA: &str = "era";
Expand Down
11 changes: 3 additions & 8 deletions zenoh/src/net/routing/hat/linkstate_peer/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,15 +773,12 @@ impl Network {
let idxs = self
.graph
.node_indices()
.filter_map(|idx| {
(self.full_linkstate
.filter(|&idx| (self.full_linkstate
|| self.gossip_multihop
|| self.links.values().any(|link| link.zid == zid)
|| (self.router_peers_failover_brokering
&& idx == self.idx
&& whatami == WhatAmI::Router))
.then(|| {
(
&& whatami == WhatAmI::Router))).map(|idx| (
idx,
Details {
zid: true,
Expand All @@ -791,9 +788,7 @@ impl Network {
&& idx == self.idx
&& whatami == WhatAmI::Router),
},
)
})
})
))
.collect();
self.send_on_link(idxs, &transport);
free_index
Expand Down
11 changes: 3 additions & 8 deletions zenoh/src/net/routing/hat/p2p_peer/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,11 @@ impl Network {
let idxs = self
.graph
.node_indices()
.filter_map(|idx| {
(self.gossip_multihop
.filter(|&idx| (self.gossip_multihop
|| self.links.values().any(|link| link.zid == zid)
|| (self.router_peers_failover_brokering
&& idx == self.idx
&& whatami == WhatAmI::Router))
.then(|| {
(
&& whatami == WhatAmI::Router))).map(|idx| (
idx,
Details {
zid: true,
Expand All @@ -525,9 +522,7 @@ impl Network {
&& idx == self.idx
&& whatami == WhatAmI::Router),
},
)
})
})
))
.collect();
self.send_on_link(idxs, &transport);
free_index
Expand Down
11 changes: 3 additions & 8 deletions zenoh/src/net/routing/hat/router/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,15 +778,12 @@ impl Network {
let idxs = self
.graph
.node_indices()
.filter_map(|idx| {
(self.full_linkstate
.filter(|&idx| (self.full_linkstate
|| self.gossip_multihop
|| self.links.values().any(|link| link.zid == zid)
|| (self.router_peers_failover_brokering
&& idx == self.idx
&& whatami == WhatAmI::Router))
.then(|| {
(
&& whatami == WhatAmI::Router))).map(|idx| (
idx,
Details {
zid: true,
Expand All @@ -796,9 +793,7 @@ impl Network {
&& idx == self.idx
&& whatami == WhatAmI::Router),
},
)
})
})
))
.collect();
self.send_on_link(idxs, &transport);
free_index
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ impl Session {
}

#[allow(clippy::new_ret_no_self)]
pub(super) fn new(config: Config) -> impl Resolve<ZResult<Session>> + Send {
pub(super) fn new(config: Config) -> impl Resolve<ZResult<Session>> {
ResolveFuture::new(async move {
log::debug!("Config: {:?}", &config);
let aggregated_subscribers = config.aggregation().subscribers().clone();
Expand Down Expand Up @@ -830,7 +830,7 @@ impl Session {
pub(crate) fn declare_prefix<'a>(
&'a self,
prefix: &'a str,
) -> impl Resolve<ExprId> + Send + 'a {
) -> impl Resolve<ExprId> + 'a {
ResolveClosure::new(move || {
trace!("declare_prefix({:?})", prefix);
let mut state = zwrite!(self.state);
Expand Down Expand Up @@ -888,7 +888,7 @@ impl Session {
pub(crate) fn declare_publication_intent<'a>(
&'a self,
_key_expr: KeyExpr<'a>,
) -> impl Resolve<Result<(), std::convert::Infallible>> + Send + 'a {
) -> impl Resolve<Result<(), std::convert::Infallible>> + 'a {
ResolveClosure::new(move || {
// log::trace!("declare_publication({:?})", key_expr);
// let mut state = zwrite!(self.state);
Expand Down
2 changes: 1 addition & 1 deletion zenoh/tests/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn create_session_pair(locator: &str) -> (Session, Session) {
config.scouting.multicast.set_enabled(Some(false)).unwrap();
config
.listen
.set_endpoints(vec![locator.clone().parse().unwrap()])
.set_endpoints(vec![locator.parse().unwrap()])
.unwrap();
config
};
Expand Down

0 comments on commit b79a615

Please sign in to comment.