This commit is contained in:
asonix 2024-05-26 13:45:49 -05:00
parent 1a79d59015
commit 3ad21bddbc

View file

@ -7,7 +7,7 @@ pub fn choose_permute<T: Clone, const SIZE: usize>(source: &[T]) -> ChoosePermut
pub fn choose<T: Clone, const SIZE: usize>(source: &[T]) -> Choose<'_, T, SIZE> { pub fn choose<T: Clone, const SIZE: usize>(source: &[T]) -> Choose<'_, T, SIZE> {
if source.len() < SIZE { if source.len() < SIZE {
panic!("Source to small to choose {SIZE} elements"); panic!("Source too small to choose {SIZE} elements");
} }
Choose { Choose {
@ -92,7 +92,7 @@ impl<T: Clone, const SIZE: usize> Permute<T, SIZE> {
self.closed = !any_updated; self.closed = !any_updated;
} }
fn permmute(&self) -> [T; SIZE] { fn permute(&self) -> [T; SIZE] {
let mut out = self.source.clone(); let mut out = self.source.clone();
for (idx, count) in self.count.iter().enumerate() { for (idx, count) in self.count.iter().enumerate() {
@ -171,7 +171,7 @@ impl<T: Clone, const SIZE: usize> Iterator for Permute<T, SIZE> {
} else { } else {
self.increment(); self.increment();
Some(self.permmute()) Some(self.permute())
} }
} }