Q:

How to zip Vec with indexed position

Following my question, How to iterate a Vec with indexed position in Rust, now I need to zip two dynamic vectors with their indexed position.

A:

The enumerate function exists for all iterators. Using zip on two iterators a and b yields another iterator. Therefor you can also call enumerate on the resulting iterator.
fn main() {
    let a = vec![1; 10];
    let b = vec![2; 10];

    let it = a.iter().zip(b.iter());

    for (i, (x, y)) in it.enumerate() {
        println!("{}: ({}, {})", i, x, y);
    }
}

