0

I am curious if rust has some buildin function to combine iterators aka. "every element from A with every element from B". Similar how haskell handles [(x,y)| x <- [1..3], y <- [3..6]]

    let t = (1..3)
        .into_iter()
        ."combine"((3..6) //Magic goes here?
            .into_iter())
        .collect::<Vec<usize>>();
    assert_eq!(t, vec![(1,3),(2,3),(1,4),(2,4)....]);

Thanks :D

Mindxxxd
  • 75
  • 6
  • 2
    The word you're looking for is the "cartesian product" of iterators. – Brian61354270 Feb 05 '23 at 16:46
  • Other related questions: [How do I get the cartesian product of 2 vectors by using Iterator?](https://stackoverflow.com/q/69613407/11082165), [How to create a function that creates a Cartesian product Iterator from an Iterator of Iterators?](https://stackoverflow.com/q/47668915/11082165) – Brian61354270 Feb 05 '23 at 16:48

0 Answers0