Skip to content

Commit 0cc792c

Browse files
authored
style: include useless_let_if_seq (#746)
1 parent ade43ce commit 0cc792c

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,5 @@ redundant_pub_crate = { level = "allow", priority = 1 }
167167
suboptimal_flops = { level = "allow", priority = 1 }
168168
suspicious_operation_groupings = { level = "allow", priority = 1 }
169169
use_self = { level = "allow", priority = 1 }
170-
useless_let_if_seq = { level = "allow", priority = 1 }
171170
# cargo-lints:
172171
cargo_common_metadata = { level = "allow", priority = 1 }

src/math/zellers_congruence_algorithm.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String {
44
let q = date;
5-
let mut m = month;
6-
let mut y = year;
7-
if month < 3 {
8-
m = month + 12;
9-
y = year - 1;
10-
}
5+
let (m, y) = if month < 3 {
6+
(month + 12, year - 1)
7+
} else {
8+
(month, year)
9+
};
1110
let day: i32 =
1211
(q + (26 * (m + 1) / 10) + (y % 100) + ((y % 100) / 4) + ((y / 100) / 4) + (5 * (y / 100)))
1312
% 7;

src/sorting/heap_sort.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ fn build_heap<T: Ord>(arr: &mut [T], is_max_heap: bool) {
3030
/// * `i` - The index to start fixing the heap violation.
3131
/// * `is_max_heap` - A boolean indicating whether to maintain a max heap or a min heap.
3232
fn heapify<T: Ord>(arr: &mut [T], i: usize, is_max_heap: bool) {
33-
let mut comparator: fn(&T, &T) -> Ordering = |a, b| a.cmp(b);
34-
if !is_max_heap {
35-
comparator = |a, b| b.cmp(a);
36-
}
33+
let comparator: fn(&T, &T) -> Ordering = if !is_max_heap {
34+
|a, b| b.cmp(a)
35+
} else {
36+
|a, b| a.cmp(b)
37+
};
3738

3839
let mut idx = i;
3940
let l = 2 * i + 1;

0 commit comments

Comments
 (0)