Skip to content

Commit d5fdacf

Browse files
committed
git
1 parent 50041e1 commit d5fdacf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/iter/combinations.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ where
346346
let k = indices.as_mut().len();
347347
let total = checked_binomial(n, k).expect(OVERFLOW_MSG);
348348
match offset.cmp(&total) {
349-
Ordering::Less => {
349+
Ordering::Equal => {
350350
unrank(indices.as_mut(), offset - 1, n);
351351
Self {
352352
indices,
353353
n,
354354
position: IndicesPosition::End,
355355
}
356356
}
357-
Ordering::Equal => {
357+
Ordering::Less => {
358358
unrank(indices.as_mut(), offset, n);
359359
Self {
360360
indices,
@@ -549,6 +549,8 @@ fn decrement_indices(indices: &mut [usize], n: usize) {
549549

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

0 commit comments

Comments
 (0)