Two variables in for loop

Hi there
in C# i can write something like:

for (int x = 0, y = 0; x <= 10 && y <= 10; x++, y++)
{
....
}

working with two vars in the loop. Is there an easy way to do this in Rust?

Thx.

You can use zip:

for (x, y) in (0..=10).zip(0..=10) {
    ...
}
4 Likes

Amazing simple...
thx

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.