pub trait IterArrayCombinationsWithReps: Iterator {
// Provided method
fn array_combinations_with_reps<const K: usize>(
self
) -> ArrayCombinationsWithReps<Self, K> ⓘ
where Self: Sized,
Self::Item: Clone { ... }
}
Available on crate feature
array_combinations_with_reps
only.Expand description
An extension trait that provides the array_combinations_with_reps
method for
iterators.
Provided Methods§
sourcefn array_combinations_with_reps<const K: usize>(
self
) -> ArrayCombinationsWithReps<Self, K> ⓘ
fn array_combinations_with_reps<const K: usize>( self ) -> ArrayCombinationsWithReps<Self, K> ⓘ
Returns an iterator adaptor that iterates over K
length combinations
with repetitions/replacements of all the elements in the underlying
iterator.
The iterator is consumed as elements are required.
Panics
If called with K = 0
.
Examples
Basic usage:
use itermore::IterArrayCombinationsWithReps;
let mut iter = "ab".chars().array_combinations_with_reps();
assert_eq!(iter.next(), Some(['a', 'a', 'a']));
assert_eq!(iter.next(), Some(['a', 'a', 'b']));
assert_eq!(iter.next(), Some(['a', 'b', 'a']));
assert_eq!(iter.next(), Some(['a', 'b', 'b']));
assert_eq!(iter.next(), Some(['b', 'a', 'a']));
// etc