Skip to content

Commit

Permalink
style: include useless_let_if_seq (TheAlgorithms#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 committed Jun 12, 2024
1 parent ade43ce commit 0cc792c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,5 @@ redundant_pub_crate = { level = "allow", priority = 1 }
suboptimal_flops = { level = "allow", priority = 1 }
suspicious_operation_groupings = { level = "allow", priority = 1 }
use_self = { level = "allow", priority = 1 }
useless_let_if_seq = { level = "allow", priority = 1 }
# cargo-lints:
cargo_common_metadata = { level = "allow", priority = 1 }
11 changes: 5 additions & 6 deletions src/math/zellers_congruence_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String {
let q = date;
let mut m = month;
let mut y = year;
if month < 3 {
m = month + 12;
y = year - 1;
}
let (m, y) = if month < 3 {
(month + 12, year - 1)
} else {
(month, year)
};
let day: i32 =
(q + (26 * (m + 1) / 10) + (y % 100) + ((y % 100) / 4) + ((y / 100) / 4) + (5 * (y / 100)))
% 7;
Expand Down
9 changes: 5 additions & 4 deletions src/sorting/heap_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ fn build_heap<T: Ord>(arr: &mut [T], is_max_heap: bool) {
/// * `i` - The index to start fixing the heap violation.
/// * `is_max_heap` - A boolean indicating whether to maintain a max heap or a min heap.
fn heapify<T: Ord>(arr: &mut [T], i: usize, is_max_heap: bool) {
let mut comparator: fn(&T, &T) -> Ordering = |a, b| a.cmp(b);
if !is_max_heap {
comparator = |a, b| b.cmp(a);
}
let comparator: fn(&T, &T) -> Ordering = if !is_max_heap {
|a, b| b.cmp(a)
} else {
|a, b| a.cmp(b)
};

let mut idx = i;
let l = 2 * i + 1;
Expand Down

0 comments on commit 0cc792c

Please sign in to comment.