pub trait IterArrayCombinations: Iterator {
    // Provided method
    fn array_combinations<const K: usize>(self) -> ArrayCombinations<Self, K> 
       where Self: Sized,
             Self::Item: Clone { ... }
}
Available on crate feature array_combinations only.
Expand description

An extension trait that provides the array_combinations method for iterators.

Provided Methods§

source

fn array_combinations<const K: usize>(self) -> ArrayCombinations<Self, K>
where Self: Sized, Self::Item: Clone,

Returns an iterator adaptor that iterates over K length combinations of all the elements in the underlying iterator.

The iterator is consumed as elements are required. In the first iteration K elements will be consumed by the iterator.

Panics

If called with K = 0.

Examples

Basic usage:

use itermore::IterArrayCombinations;

let mut iter = "abcd".chars().array_combinations();
assert_eq!(iter.next(), Some(['a', 'b', 'c']));
assert_eq!(iter.next(), Some(['a', 'b', 'd']));
assert_eq!(iter.next(), Some(['a', 'c', 'd']));
assert_eq!(iter.next(), Some(['b', 'c', 'd']));
assert_eq!(iter.next(), None);

Implementors§

source§

impl<I> IterArrayCombinations for I
where I: Iterator + ?Sized,