Skip to content

Commit 2a7b509

Browse files
Philippe-Choletjswrenn
authored andcommitted
Use try_fold in combinations_with_replacement::remaining_for
1 parent b30cff7 commit 2a7b509

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/combinations_with_replacement.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ fn remaining_for(n: usize, first: bool, indices: &[usize]) -> Option<usize> {
157157
indices
158158
.iter()
159159
.enumerate()
160-
.fold(Some(0), |sum, (i, n0)| {
161-
sum.and_then(|s| s.checked_add(count(n - 1 - *n0, k - i)?))
160+
.try_fold(0usize, |sum, (i, n0)| {
161+
sum.checked_add(count(n - 1 - *n0, k - i)?)
162162
})
163163
}
164164
}

0 commit comments

Comments
 (0)