Skip to content

Commit bef0014

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

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/powerset.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<I> FusedIterator for Powerset<I>
8282
{}
8383

8484
fn remaining_for(n: usize, k: usize) -> Option<usize> {
85-
(k + 1..=n).fold(Some(0), |sum, i| {
86-
sum.and_then(|s| s.checked_add(checked_binomial(n, i)?))
85+
(k + 1..=n).try_fold(0usize, |sum, i| {
86+
sum.checked_add(checked_binomial(n, i)?)
8787
})
8888
}

0 commit comments

Comments
 (0)