From f1447655abc815fe6faddb84f7b73547680dead7 Mon Sep 17 00:00:00 2001 From: mxsm Date: Sat, 16 Nov 2024 23:08:02 +0800 Subject: [PATCH 1/3] [ISSUE #1180]Fix cargo clippy -- -D warnings error --- rocketmq-common/src/utils/string_utils.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rocketmq-common/src/utils/string_utils.rs b/rocketmq-common/src/utils/string_utils.rs index fa65c660..b3eaa916 100644 --- a/rocketmq-common/src/utils/string_utils.rs +++ b/rocketmq-common/src/utils/string_utils.rs @@ -21,17 +21,17 @@ pub struct StringUtils; impl StringUtils { #[inline] pub fn is_not_empty_str(s: Option<&str>) -> bool { - s.map_or(false, |s| !s.is_empty()) + s.is_some_and(|s| !s.is_empty()) } #[inline] pub fn is_not_empty_string(s: Option<&String>) -> bool { - s.map_or(false, |s| !s.is_empty()) + s.is_some_and(|s| !s.is_empty()) } #[inline] pub fn is_not_empty_ch_string(s: Option<&CheetahString>) -> bool { - s.map_or(false, |s| !s.is_empty()) + s.is_some_and(|s| !s.is_empty()) } } From 3f07fa0c4843fef3679aa652d0afac81e5c823c0 Mon Sep 17 00:00:00 2001 From: mxsm Date: Sat, 16 Nov 2024 23:12:22 +0800 Subject: [PATCH 2/3] fix code style --- rocketmq-store/src/log_file/commit_log.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketmq-store/src/log_file/commit_log.rs b/rocketmq-store/src/log_file/commit_log.rs index 91a054f6..b810dec8 100644 --- a/rocketmq-store/src/log_file/commit_log.rs +++ b/rocketmq-store/src/log_file/commit_log.rs @@ -793,7 +793,7 @@ impl CommitLog { pub fn is_multi_dispatch_msg(msg_inner: &MessageExtBrokerInner) -> bool { msg_inner .property(MessageConst::PROPERTY_INNER_MULTI_DISPATCH) - .map_or(false, |s| !s.is_empty()) + .is_some_and(|s| !s.is_empty()) && msg_inner .topic() .starts_with(mix_all::RETRY_GROUP_TOPIC_PREFIX) From 0ab4f8e2d7d3d58ee720217e05246b82fc466f14 Mon Sep 17 00:00:00 2001 From: mxsm Date: Sat, 16 Nov 2024 23:16:33 +0800 Subject: [PATCH 3/3] fix code style --- rocketmq-broker/src/processor/pull_message_processor.rs | 2 +- rocketmq-broker/src/processor/send_message_processor.rs | 5 ++--- .../src/consumer/consumer_impl/pull_api_wrapper.rs | 2 +- rocketmq-client/src/implementation/mq_client_api_impl.rs | 2 +- rocketmq-namesrv/src/route/route_info_manager.rs | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/rocketmq-broker/src/processor/pull_message_processor.rs b/rocketmq-broker/src/processor/pull_message_processor.rs index e4932600..65509033 100644 --- a/rocketmq-broker/src/processor/pull_message_processor.rs +++ b/rocketmq-broker/src/processor/pull_message_processor.rs @@ -868,7 +868,7 @@ pub(crate) fn is_broadcast( consumer_group_info: Option<&ConsumerGroupInfo>, ) -> bool { proxy_pull_broadcast - || consumer_group_info.map_or(false, |info| { + || consumer_group_info.is_some_and(|info| { matches!(info.get_message_model(), MessageModel::Broadcasting) && matches!(info.get_consume_type(), ConsumeType::ConsumePassively) }) diff --git a/rocketmq-broker/src/processor/send_message_processor.rs b/rocketmq-broker/src/processor/send_message_processor.rs index efd520f9..3d976016 100644 --- a/rocketmq-broker/src/processor/send_message_processor.rs +++ b/rocketmq-broker/src/processor/send_message_processor.rs @@ -515,9 +515,8 @@ where message_ext.properties_string = MessageDecoder::message_properties_to_string( &message_ext.message_ext_inner.message.properties, ); - let tra_flag = tra_flag.map_or(false, |tra_flag_inner| { - tra_flag_inner.parse().unwrap_or(false) - }); + let tra_flag = + tra_flag.is_some_and(|tra_flag_inner| tra_flag_inner.parse().unwrap_or(false)); let send_transaction_prepare_message = if tra_flag diff --git a/rocketmq-client/src/consumer/consumer_impl/pull_api_wrapper.rs b/rocketmq-client/src/consumer/consumer_impl/pull_api_wrapper.rs index ef423361..39cccefb 100644 --- a/rocketmq-client/src/consumer/consumer_impl/pull_api_wrapper.rs +++ b/rocketmq-client/src/consumer/consumer_impl/pull_api_wrapper.rs @@ -172,7 +172,7 @@ impl PullAPIWrapper { .get_property(&CheetahString::from_static_str( MessageConst::PROPERTY_TRANSACTION_PREPARED, )) - .map_or(false, |v| v.parse().unwrap_or(false)); + .is_some_and(|v| v.parse().unwrap_or(false)); if tra_flag { if let Some(transaction_id) = msg.get_property(&CheetahString::from_static_str( MessageConst::PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX, diff --git a/rocketmq-client/src/implementation/mq_client_api_impl.rs b/rocketmq-client/src/implementation/mq_client_api_impl.rs index 6f7326f7..f220eb5f 100644 --- a/rocketmq-client/src/implementation/mq_client_api_impl.rs +++ b/rocketmq-client/src/implementation/mq_client_api_impl.rs @@ -571,7 +571,7 @@ impl MQClientAPIImpl { .ext_fields() .unwrap() .get(MessageConst::PROPERTY_TRACE_SWITCH) - .map_or(false, |s| s.parse().unwrap_or(false)); + .is_some_and(|s| s.parse().unwrap_or(false)); let send_result = SendResult { send_status, msg_id: uniq_msg_id, diff --git a/rocketmq-namesrv/src/route/route_info_manager.rs b/rocketmq-namesrv/src/route/route_info_manager.rs index fab26031..f29dd659 100644 --- a/rocketmq-namesrv/src/route/route_info_manager.rs +++ b/rocketmq-namesrv/src/route/route_info_manager.rs @@ -1047,7 +1047,7 @@ impl RouteInfoManager { if self .broker_addr_table .get(broker_name) - .map_or(false, |b| b.enable_acting_master()) + .is_some_and(|b| b.enable_acting_master()) { // Master has been unregistered, wipe the write perm let flag = {