How to zip two Vecs together

Use Vec::iter().zip() to pair elements from two vectors into an iterator of tuples.

Use the iter().zip() method to pair elements from two Vecs into an iterator of tuples.

let a = vec![1, 2, 3];
let b = vec!['a', 'b', 'c'];

let zipped: Vec<(i32, char)> = a.iter().zip(b.iter()).collect();

This creates a new Vec containing (&1, &'a'), (&2, &'b'), and (&3, &'c').