Trait itermore::IterCombinationsWithReps
source · pub trait IterCombinationsWithReps: Iterator {
// Provided method
fn combinations_with_reps(self, k: usize) -> CombinationsWithReps<Self> ⓘ
where Self: Sized,
Self::Item: Clone { ... }
}
Available on crate feature
combinations_with_reps
only.Expand description
An extension trait that provides the combinations_with_reps
method for
iterators.
Provided Methods§
sourcefn combinations_with_reps(self, k: usize) -> CombinationsWithReps<Self> ⓘ
fn combinations_with_reps(self, k: usize) -> CombinationsWithReps<Self> ⓘ
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::IterCombinationsWithReps;
let mut iter = "ab".chars().combinations_with_reps(3);
assert_eq!(iter.next(), Some(vec!['a', 'a', 'a']));
assert_eq!(iter.next(), Some(vec!['a', 'a', 'b']));
assert_eq!(iter.next(), Some(vec!['a', 'b', 'a']));
assert_eq!(iter.next(), Some(vec!['a', 'b', 'b']));
assert_eq!(iter.next(), Some(vec!['b', 'a', 'a']));
// etc