Handle choose SIZE == source len
This commit is contained in:
parent
3ad21bddbc
commit
54c8738a96
1 changed files with 5 additions and 1 deletions
|
@ -156,7 +156,11 @@ impl<'a, T: Clone, const SIZE: usize> Iterator for Choose<'a, T, SIZE> {
|
|||
let numerator = factorial(self.source.len());
|
||||
let denominator = factorial(SIZE) * factorial(self.source.len() - SIZE);
|
||||
|
||||
let size = numerator / denominator;
|
||||
let size = if denominator == 0 {
|
||||
1
|
||||
} else {
|
||||
numerator / denominator
|
||||
};
|
||||
|
||||
(size, Some(size))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue