From c4a164b328682185dd4df6ae7ffa024a95f98ce2 Mon Sep 17 00:00:00 2001 From: Rina Fujino Date: Thu, 9 Jan 2025 17:11:10 +0100 Subject: [PATCH] fix: clippy warning unnecessary_map_or Signed-off-by: Rina Fujino --- crates/common/tedge_config_macros/impl/src/input/validate.rs | 2 +- crates/core/tedge/src/cli/connect/command.rs | 2 +- crates/core/tedge/src/main.rs | 2 +- crates/extensions/c8y_auth_proxy/src/server.rs | 4 +--- crates/extensions/tedge_mqtt_bridge/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/common/tedge_config_macros/impl/src/input/validate.rs b/crates/common/tedge_config_macros/impl/src/input/validate.rs index b9c3667739a..6c9a7223943 100644 --- a/crates/common/tedge_config_macros/impl/src/input/validate.rs +++ b/crates/common/tedge_config_macros/impl/src/input/validate.rs @@ -117,7 +117,7 @@ impl FieldOrGroup { pub fn is_called(&self, target: &syn::Ident) -> bool { self.ident() == target || match self { - Self::Field(field) => field.rename().map_or(false, |rename| *target == rename), + Self::Field(field) => field.rename().is_some_and(|rename| *target == rename), // Groups don't support renaming at the moment Self::Group(_) => false, Self::Multi(_) => false, diff --git a/crates/core/tedge/src/cli/connect/command.rs b/crates/core/tedge/src/cli/connect/command.rs index 1a9d79858d4..baa9ecdd458 100644 --- a/crates/core/tedge/src/cli/connect/command.rs +++ b/crates/core/tedge/src/cli/connect/command.rs @@ -528,7 +528,7 @@ fn bridge_health_topic( fn is_bridge_health_up_message(message: &rumqttc::Publish, health_topic: &str) -> bool { message.topic == health_topic - && std::str::from_utf8(&message.payload).map_or(false, |msg| msg.contains("\"up\"")) + && std::str::from_utf8(&message.payload).is_ok_and(|msg| msg.contains("\"up\"")) } // Check the connection by using the jwt token retrieval over the mqtt. diff --git a/crates/core/tedge/src/main.rs b/crates/core/tedge/src/main.rs index a36d7c1c67a..ecb09f093fa 100644 --- a/crates/core/tedge/src/main.rs +++ b/crates/core/tedge/src/main.rs @@ -145,7 +145,7 @@ where let is_known_subcommand = executable_name .as_deref() - .map_or(false, |name| cmd.find_subcommand(name).is_some()); + .is_some_and(|name| cmd.find_subcommand(name).is_some()); let cmd = cmd.multicall(is_known_subcommand); let cmd2 = cmd.clone(); diff --git a/crates/extensions/c8y_auth_proxy/src/server.rs b/crates/extensions/c8y_auth_proxy/src/server.rs index 2e010af559f..4b21b0df3ed 100644 --- a/crates/extensions/c8y_auth_proxy/src/server.rs +++ b/crates/extensions/c8y_auth_proxy/src/server.rs @@ -478,9 +478,7 @@ async fn respond_to( let status = res.status(); let headers = std::mem::take(res.headers_mut()); - let body = if te_header.map_or(false, |h| { - h.to_str().unwrap_or_default().contains("chunked") - }) { + let body = if te_header.is_some_and(|h| h.to_str().unwrap_or_default().contains("chunked")) { axum::body::boxed(StreamBody::new(res.bytes_stream())) } else { axum::body::boxed(Full::new( diff --git a/crates/extensions/tedge_mqtt_bridge/src/lib.rs b/crates/extensions/tedge_mqtt_bridge/src/lib.rs index 191a1028edc..9a4b060f6af 100644 --- a/crates/extensions/tedge_mqtt_bridge/src/lib.rs +++ b/crates/extensions/tedge_mqtt_bridge/src/lib.rs @@ -647,7 +647,7 @@ impl MessageLoopBreaker { if self .forwarded_messages .front() - .map_or(false, |(_, sent)| have_same_content(sent, &received)) + .is_some_and(|(_, sent)| have_same_content(sent, &received)) { self.client.ack(&received).await.unwrap(); self.forwarded_messages.pop_front();