Skip to content

Commit 90de4ae

Browse files
authored
Merge pull request #3321 from rina23q/fix/clippy-warning-unnecessary-unwrap-or
refactor: clippy warning unnecessary_map_or
2 parents bd06fcb + c4a164b commit 90de4ae

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

crates/common/tedge_config_macros/impl/src/input/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl FieldOrGroup {
117117
pub fn is_called(&self, target: &syn::Ident) -> bool {
118118
self.ident() == target
119119
|| match self {
120-
Self::Field(field) => field.rename().map_or(false, |rename| *target == rename),
120+
Self::Field(field) => field.rename().is_some_and(|rename| *target == rename),
121121
// Groups don't support renaming at the moment
122122
Self::Group(_) => false,
123123
Self::Multi(_) => false,

crates/core/tedge/src/cli/connect/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ fn bridge_health_topic(
528528

529529
fn is_bridge_health_up_message(message: &rumqttc::Publish, health_topic: &str) -> bool {
530530
message.topic == health_topic
531-
&& std::str::from_utf8(&message.payload).map_or(false, |msg| msg.contains("\"up\""))
531+
&& std::str::from_utf8(&message.payload).is_ok_and(|msg| msg.contains("\"up\""))
532532
}
533533

534534
// Check the connection by using the jwt token retrieval over the mqtt.

crates/core/tedge/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ where
145145

146146
let is_known_subcommand = executable_name
147147
.as_deref()
148-
.map_or(false, |name| cmd.find_subcommand(name).is_some());
148+
.is_some_and(|name| cmd.find_subcommand(name).is_some());
149149
let cmd = cmd.multicall(is_known_subcommand);
150150

151151
let cmd2 = cmd.clone();

crates/extensions/c8y_auth_proxy/src/server.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,7 @@ async fn respond_to(
478478
let status = res.status();
479479
let headers = std::mem::take(res.headers_mut());
480480

481-
let body = if te_header.map_or(false, |h| {
482-
h.to_str().unwrap_or_default().contains("chunked")
483-
}) {
481+
let body = if te_header.is_some_and(|h| h.to_str().unwrap_or_default().contains("chunked")) {
484482
axum::body::boxed(StreamBody::new(res.bytes_stream()))
485483
} else {
486484
axum::body::boxed(Full::new(

crates/extensions/tedge_mqtt_bridge/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ impl<Ack: MqttAck, Clock: MonotonicClock> MessageLoopBreaker<Ack, Clock> {
647647
if self
648648
.forwarded_messages
649649
.front()
650-
.map_or(false, |(_, sent)| have_same_content(sent, &received))
650+
.is_some_and(|(_, sent)| have_same_content(sent, &received))
651651
{
652652
self.client.ack(&received).await.unwrap();
653653
self.forwarded_messages.pop_front();

0 commit comments

Comments
 (0)