Skip to content

Commit b20f4af

Browse files
[ISSUE #4087]♻️Clean up existing clippy warnings of types:
- useless_vec - redundant_field_names - let_unit_value - manual_range_contains
1 parent 49a9baa commit b20f4af

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,26 @@ mod tests {
6565
let mut all_acl_config_data_version = HashMap::new();
6666
all_acl_config_data_version.insert(CheetahString::from("key1"), DataVersion::default());
6767

68-
let _info1 = ClusterAclVersionInfo {
68+
let info1 = ClusterAclVersionInfo {
6969
broker_name: CheetahString::from("broker1"),
7070
broker_addr: CheetahString::from("addr1"),
7171
acl_config_data_version: Some(DataVersion::default()),
7272
all_acl_config_data_version: all_acl_config_data_version.clone(),
7373
cluster_name: CheetahString::from("cluster1"),
7474
};
7575

76-
let _info2 = ClusterAclVersionInfo {
76+
let info2 = ClusterAclVersionInfo {
7777
broker_name: CheetahString::from("broker1"),
7878
broker_addr: CheetahString::from("addr1"),
7979
acl_config_data_version: Some(DataVersion::default()),
80-
all_acl_config_data_version: all_acl_config_data_version,
80+
all_acl_config_data_version,
8181
cluster_name: CheetahString::from("cluster1"),
8282
};
83+
84+
assert_eq!(
85+
serde_json::to_string(&info1).unwrap(),
86+
serde_json::to_string(&info2).unwrap()
87+
);
8388
}
8489

8590
#[test]
@@ -110,7 +115,7 @@ mod tests {
110115
broker_name: CheetahString::from("broker1"),
111116
broker_addr: CheetahString::from("addr1"),
112117
acl_config_data_version: Some(DataVersion::default()),
113-
all_acl_config_data_version: all_acl_config_data_version,
118+
all_acl_config_data_version,
114119
cluster_name: CheetahString::from("cluster1"),
115120
};
116121
let serialized = serde_json::to_string(&info).unwrap();

rocketmq-remoting/src/protocol/header/extra_info_util.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,13 @@ mod tests {
506506

507507
#[test]
508508
fn get_ck_queue_offset_with_valid_string() {
509-
let result = ExtraInfoUtil::get_ck_queue_offset(&vec!["123".to_string()]).unwrap();
509+
let result = ExtraInfoUtil::get_ck_queue_offset(&["123".to_string()]).unwrap();
510510
assert_eq!(result, 123);
511511
}
512512

513513
#[test]
514514
fn get_ck_queue_offset_with_invalid_string() {
515-
let result = ExtraInfoUtil::get_ck_queue_offset(&vec!["abc".to_string()]).unwrap_err();
515+
let result = ExtraInfoUtil::get_ck_queue_offset(&["abc".to_string()]).unwrap_err();
516516
assert_eq!(
517517
result.to_string(),
518518
IllegalArgument("parse ck_queue_offset error".to_string()).to_string()
@@ -521,14 +521,13 @@ mod tests {
521521

522522
#[test]
523523
fn get_pop_time_with_valid_string() {
524-
let result =
525-
ExtraInfoUtil::get_pop_time(&vec!["123".to_string(), "456".to_string()]).unwrap();
524+
let result = ExtraInfoUtil::get_pop_time(&["123".to_string(), "456".to_string()]).unwrap();
526525
assert_eq!(result, 456);
527526
}
528527

529528
#[test]
530529
fn get_pop_time_with_insufficient_length() {
531-
let result = ExtraInfoUtil::get_pop_time(&vec!["123".to_string()]).unwrap_err();
530+
let result = ExtraInfoUtil::get_pop_time(&["123".to_string()]).unwrap_err();
532531
assert_eq!(
533532
result.to_string(),
534533
IllegalArgument("getPopTime fail, extraInfoStrs length 1".to_string()).to_string()
@@ -537,7 +536,7 @@ mod tests {
537536

538537
#[test]
539538
fn get_invisible_time_with_valid_string() {
540-
let result = ExtraInfoUtil::get_invisible_time(&vec![
539+
let result = ExtraInfoUtil::get_invisible_time(&[
541540
"123".to_string(),
542541
"456".to_string(),
543542
"789".to_string(),
@@ -548,8 +547,8 @@ mod tests {
548547

549548
#[test]
550549
fn get_invisible_time_with_insufficient_length() {
551-
let result = ExtraInfoUtil::get_invisible_time(&vec!["123".to_string(), "456".to_string()])
552-
.unwrap_err();
550+
let result =
551+
ExtraInfoUtil::get_invisible_time(&["123".to_string(), "456".to_string()]).unwrap_err();
553552
assert_eq!(
554553
result.to_string(),
555554
IllegalArgument("getInvisibleTime fail, extraInfoStrs length 2".to_string())
@@ -559,7 +558,7 @@ mod tests {
559558

560559
#[test]
561560
fn get_revive_qid_with_valid_string() {
562-
let result = ExtraInfoUtil::get_revive_qid(&vec![
561+
let result = ExtraInfoUtil::get_revive_qid(&[
563562
"123".to_string(),
564563
"456".to_string(),
565564
"789".to_string(),
@@ -571,7 +570,7 @@ mod tests {
571570

572571
#[test]
573572
fn get_revive_qid_with_insufficient_length() {
574-
let result = ExtraInfoUtil::get_revive_qid(&vec![
573+
let result = ExtraInfoUtil::get_revive_qid(&[
575574
"123".to_string(),
576575
"456".to_string(),
577576
"789".to_string(),
@@ -586,7 +585,7 @@ mod tests {
586585
#[test]
587586
fn get_real_topic_with_retry_v1() {
588587
let result = ExtraInfoUtil::get_real_topic(
589-
&vec![
588+
&[
590589
"123".to_string(),
591590
"456".to_string(),
592591
"789".to_string(),
@@ -603,7 +602,7 @@ mod tests {
603602
#[test]
604603
fn get_real_topic_with_retry_v2() {
605604
let result = ExtraInfoUtil::get_real_topic(
606-
&vec![
605+
&[
607606
"123".to_string(),
608607
"456".to_string(),
609608
"789".to_string(),
@@ -620,7 +619,7 @@ mod tests {
620619
#[test]
621620
fn get_real_topic_with_normal_topic() {
622621
let result = ExtraInfoUtil::get_real_topic(
623-
&vec![
622+
&[
624623
"123".to_string(),
625624
"456".to_string(),
626625
"789".to_string(),
@@ -637,7 +636,7 @@ mod tests {
637636
#[test]
638637
fn get_real_topic_with_insufficient_length() {
639638
let result = ExtraInfoUtil::get_real_topic(
640-
&vec![
639+
&[
641640
"123".to_string(),
642641
"456".to_string(),
643642
"789".to_string(),
@@ -664,7 +663,7 @@ mod tests {
664663

665664
#[test]
666665
fn get_retry_slice_with_valid_string() {
667-
let result = ExtraInfoUtil::get_retry(&vec![
666+
let result = ExtraInfoUtil::get_retry(&[
668667
"123".to_string(),
669668
"456".to_string(),
670669
"789".to_string(),
@@ -677,7 +676,7 @@ mod tests {
677676

678677
#[test]
679678
fn get_retry_slice_with_insufficient_length() {
680-
let result = ExtraInfoUtil::get_retry(&vec![
679+
let result = ExtraInfoUtil::get_retry(&[
681680
"123".to_string(),
682681
"456".to_string(),
683682
"789".to_string(),
@@ -692,7 +691,7 @@ mod tests {
692691

693692
#[test]
694693
fn get_broker_name_with_valid_string() {
695-
let result = ExtraInfoUtil::get_broker_name(&vec![
694+
let result = ExtraInfoUtil::get_broker_name(&[
696695
"123".to_string(),
697696
"456".to_string(),
698697
"789".to_string(),
@@ -706,7 +705,7 @@ mod tests {
706705

707706
#[test]
708707
fn get_broker_name_with_insufficient_length() {
709-
let result = ExtraInfoUtil::get_broker_name(&vec![
708+
let result = ExtraInfoUtil::get_broker_name(&[
710709
"123".to_string(),
711710
"456".to_string(),
712711
"789".to_string(),
@@ -722,7 +721,7 @@ mod tests {
722721

723722
#[test]
724723
fn get_queue_id_with_valid_string() {
725-
let result = ExtraInfoUtil::get_queue_id(&vec![
724+
let result = ExtraInfoUtil::get_queue_id(&[
726725
"123".to_string(),
727726
"456".to_string(),
728727
"789".to_string(),
@@ -737,7 +736,7 @@ mod tests {
737736

738737
#[test]
739738
fn get_queue_id_with_insufficient_length() {
740-
let result = ExtraInfoUtil::get_queue_id(&vec![
739+
let result = ExtraInfoUtil::get_queue_id(&[
741740
"123".to_string(),
742741
"456".to_string(),
743742
"789".to_string(),
@@ -754,7 +753,7 @@ mod tests {
754753

755754
#[test]
756755
fn get_queue_offset_with_valid_string() {
757-
let result = ExtraInfoUtil::get_queue_offset(&vec![
756+
let result = ExtraInfoUtil::get_queue_offset(&[
758757
"123".to_string(),
759758
"456".to_string(),
760759
"789".to_string(),
@@ -770,7 +769,7 @@ mod tests {
770769

771770
#[test]
772771
fn get_queue_offset_with_insufficient_length() {
773-
let result = ExtraInfoUtil::get_queue_offset(&vec![
772+
let result = ExtraInfoUtil::get_queue_offset(&[
774773
"123".to_string(),
775774
"456".to_string(),
776775
"789".to_string(),
@@ -830,7 +829,7 @@ mod tests {
830829
#[test]
831830
fn build_msg_offset_info_creates_correct_string() {
832831
let mut string_builder = String::new();
833-
ExtraInfoUtil::build_msg_offset_info(&mut string_builder, "topic", 7, &vec![100, 200, 300]);
832+
ExtraInfoUtil::build_msg_offset_info(&mut string_builder, "topic", 7, &[100, 200, 300]);
834833
assert_eq!(string_builder, "0 7 100;200;300");
835834
}
836835

@@ -897,7 +896,7 @@ mod tests {
897896

898897
#[test]
899898
fn is_order_with_order_queue() {
900-
let result = ExtraInfoUtil::is_order(&vec![
899+
let result = ExtraInfoUtil::is_order(&[
901900
"123".to_string(),
902901
"456".to_string(),
903902
"789".to_string(),
@@ -913,7 +912,7 @@ mod tests {
913912

914913
#[test]
915914
fn is_order_with_non_order_queue() {
916-
let result = ExtraInfoUtil::is_order(&vec![
915+
let result = ExtraInfoUtil::is_order(&[
917916
"123".to_string(),
918917
"456".to_string(),
919918
"789".to_string(),

rocketmq/src/schedule.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ mod tests {
747747
},
748748
);
749749

750-
let _ = tokio::time::sleep(Duration::from_secs(1));
751-
let _ = manager.cancel_task(task_id);
750+
time::sleep(Duration::from_millis(400)).await;
751+
manager.cancel_task(task_id);
752752
assert_eq!(manager.task_count(), 0);
753753
}
754754

@@ -806,7 +806,7 @@ mod tests {
806806

807807
let executed = counter.load(Ordering::Relaxed);
808808
assert!(
809-
executed >= 3 && executed <= 6,
809+
(3..=6).contains(&executed),
810810
"FixedDelay count unexpected: {}",
811811
executed
812812
);
@@ -835,7 +835,7 @@ mod tests {
835835

836836
let executed = counter.load(Ordering::Relaxed);
837837
assert!(
838-
executed >= 2 && executed <= 5,
838+
(2..=5).contains(&executed),
839839
"FixedRateNoOverlap count unexpected: {}",
840840
executed
841841
);

0 commit comments

Comments
 (0)