Skip to content

Commit

Permalink
Make Clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrogs committed Oct 1, 2024
1 parent 73598ce commit 5bbbe24
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/iter/combinations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,26 @@ where
fn new(mut indices: I, offset: usize, n: usize) -> Self {
let k = indices.as_mut().len();
let total = checked_binomial(n, k).expect(OVERFLOW_MSG);
if offset == total {
unrank(indices.as_mut(), offset - 1, n);
Self {
indices,
n,
position: IndicesPosition::End,
match offset.cmp(&total) {
Ordering::Equal => {
unrank(indices.as_mut(), offset - 1, n);
Self {
indices,
n,
position: IndicesPosition::End,
}
}
} else if offset < total {
unrank(indices.as_mut(), offset, n);
Self {
indices,
n,
position: IndicesPosition::Middle,
Ordering::Less => {
unrank(indices.as_mut(), offset, n);
Self {
indices,
n,
position: IndicesPosition::Middle,
}
}
Ordering::Greater => {
panic!("Offset should be inside the bounds of the possible combinations.")
}
} else {
panic!("Offset should be inside the bounds of the possible combinations.")
}
}

Expand Down Expand Up @@ -545,8 +549,10 @@ fn decrement_indices(indices: &mut [usize], n: usize) {

// Decrement index, and reset the ones to its right
indices[i] -= 1;
for j in i + 1..indices.len() {
indices[j] = n - k + j;
for (j, index) in indices.iter_mut().enumerate().skip(i + 1) {
*index = n - k + j;
for (j, index) in indices.iter_mut().enumerate().skip(i + 1) {
*index = n - k + j;
}
}

Expand Down

0 comments on commit 5bbbe24

Please sign in to comment.