fn set_product<T>(items: &[T]) -> impl Iterator<Item = Vec<&T>> {
(1..=items.len()).flat_map(|n| { std::iter::repeat(items.iter()).take(n).multi_cartesian_product()
})
}
fn main() {
for digits in set_product(&["a", "b", "c", "d", "e"]) {
println!("{:?}", digits);
}
["a"]
["b"]
["c"]
["d"]
["e"]
["a", "a"]
["a", "b"]
["a", "c"]
["a", "d"]
["a", "e"]
["b", "a"]
["b", "b"]
["b", "c"]
["b", "d"]
["b", "e"]
...
...
Print this sequence from the above function?