Handle choose SIZE == source len

This commit is contained in:
asonix 2024-05-26 13:48:11 -05:00
parent 3ad21bddbc
commit 54c8738a96

View file

@ -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))
}