From 507cf90e142fcf2fd16361e84b9a8cd30d95b815 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Fri, 10 Jan 2025 15:13:09 +0100 Subject: [PATCH] Fix Rust 1.84 clippy lints --- commons/zenoh-keyexpr/src/key_expr/format/mod.rs | 2 +- commons/zenoh-keyexpr/src/key_expr/format/parsing.rs | 2 +- commons/zenoh-protocol/src/core/endpoint.rs | 2 +- zenoh/src/api/session.rs | 4 ++-- zenoh/src/net/routing/hat/client/queries.rs | 4 ++-- zenoh/src/net/routing/hat/linkstate_peer/queries.rs | 2 +- zenoh/src/net/routing/hat/p2p_peer/queries.rs | 2 +- zenoh/src/net/routing/hat/router/queries.rs | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/commons/zenoh-keyexpr/src/key_expr/format/mod.rs b/commons/zenoh-keyexpr/src/key_expr/format/mod.rs index 8417e37eab..99cb460c8a 100644 --- a/commons/zenoh-keyexpr/src/key_expr/format/mod.rs +++ b/commons/zenoh-keyexpr/src/key_expr/format/mod.rs @@ -372,7 +372,7 @@ impl<'s, Storage: IKeFormatStorage<'s>> core::fmt::Debug for KeFormatter<'s, Sto let sharp = if id.contains('}') || pattern.contains('}') || value.map_or_else( - || spec.default().map_or(false, |v| v.contains('}')), + || spec.default().is_some_and(|v| v.contains('}')), |v| v.contains('}'), ) { "#" diff --git a/commons/zenoh-keyexpr/src/key_expr/format/parsing.rs b/commons/zenoh-keyexpr/src/key_expr/format/parsing.rs index a6329cdf73..d63d978c6d 100644 --- a/commons/zenoh-keyexpr/src/key_expr/format/parsing.rs +++ b/commons/zenoh-keyexpr/src/key_expr/format/parsing.rs @@ -221,7 +221,7 @@ fn do_parse<'a>( } } pattern.is_double_wild() - && prefix.map_or(false, |prefix| prefix.intersects(target)) + && prefix.is_some_and(|prefix| prefix.intersects(target)) && do_parse(None, segments, results) } _ => unreachable!(), diff --git a/commons/zenoh-protocol/src/core/endpoint.rs b/commons/zenoh-protocol/src/core/endpoint.rs index 081463eb43..c1b32f33a7 100644 --- a/commons/zenoh-protocol/src/core/endpoint.rs +++ b/commons/zenoh-protocol/src/core/endpoint.rs @@ -490,7 +490,7 @@ impl EndPoint { let m: &str = metadata.as_ref(); let c: &str = config.as_ref(); - let len = p.as_bytes().len() + a.as_bytes().len() + m.as_bytes().len(); + let len = p.len() + a.len() + m.len(); if len > u8::MAX as usize { bail!("Endpoint too big: {} bytes. Max: {} bytes. ", len, u8::MAX); } diff --git a/zenoh/src/api/session.rs b/zenoh/src/api/session.rs index 5a5785c20d..fc1d128165 100644 --- a/zenoh/src/api/session.rs +++ b/zenoh/src/api/session.rs @@ -1916,13 +1916,13 @@ impl SessionInner { MatchingStatusType::Queryables(false) => state.queryables.values().any(|q| { state .local_wireexpr_to_expr(&q.key_expr) - .map_or(false, |ke| ke.intersects(key_expr)) + .is_ok_and(|ke| ke.intersects(key_expr)) }), MatchingStatusType::Queryables(true) => state.queryables.values().any(|q| { q.complete && state .local_wireexpr_to_expr(&q.key_expr) - .map_or(false, |ke| ke.includes(key_expr)) + .is_ok_and(|ke| ke.includes(key_expr)) }), }; MatchingStatus { matching } diff --git a/zenoh/src/net/routing/hat/client/queries.rs b/zenoh/src/net/routing/hat/client/queries.rs index 5c5c9c905c..a7b07f407b 100644 --- a/zenoh/src/net/routing/hat/client/queries.rs +++ b/zenoh/src/net/routing/hat/client/queries.rs @@ -468,7 +468,7 @@ impl HatQueriesTrait for HatCode { qbl.session_ctxs .get(&face.id) .and_then(|sc| sc.qabl) - .map_or(false, |q| q.complete) + .is_some_and(|q| q.complete) && KeyExpr::keyexpr_include(qbl.expr(), key_expr) } false => KeyExpr::keyexpr_intersect(qbl.expr(), key_expr), @@ -493,7 +493,7 @@ impl HatQueriesTrait for HatCode { for (sid, context) in &mres.session_ctxs { if context.face.whatami == WhatAmI::Client && match complete { - true => context.qabl.map_or(false, |q| q.complete), + true => context.qabl.is_some_and(|q| q.complete), false => context.qabl.is_some(), } { diff --git a/zenoh/src/net/routing/hat/linkstate_peer/queries.rs b/zenoh/src/net/routing/hat/linkstate_peer/queries.rs index 6e286a52af..c122d369b5 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/queries.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/queries.rs @@ -1074,7 +1074,7 @@ impl HatQueriesTrait for HatCode { for (sid, context) in &mres.session_ctxs { if match complete { - true => context.qabl.map_or(false, |q| q.complete), + true => context.qabl.is_some_and(|q| q.complete), false => context.qabl.is_some(), } { matching_queryables diff --git a/zenoh/src/net/routing/hat/p2p_peer/queries.rs b/zenoh/src/net/routing/hat/p2p_peer/queries.rs index 0791e6c655..664822f6fe 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/queries.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/queries.rs @@ -719,7 +719,7 @@ impl HatQueriesTrait for HatCode { } for (sid, context) in &mres.session_ctxs { if match complete { - true => context.qabl.map_or(false, |q| q.complete), + true => context.qabl.is_some_and(|q| q.complete), false => context.qabl.is_some(), } { matching_queryables diff --git a/zenoh/src/net/routing/hat/router/queries.rs b/zenoh/src/net/routing/hat/router/queries.rs index 9896b691ba..97a772a9df 100644 --- a/zenoh/src/net/routing/hat/router/queries.rs +++ b/zenoh/src/net/routing/hat/router/queries.rs @@ -1575,7 +1575,7 @@ impl HatQueriesTrait for HatCode { if master { for (sid, context) in &mres.session_ctxs { if match complete { - true => context.qabl.map_or(false, |q| q.complete), + true => context.qabl.is_some_and(|q| q.complete), false => context.qabl.is_some(), } && context.face.whatami != WhatAmI::Router {