Rust tips is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Rust tips @rust

Iterate two things together at once:

iter1.zip(iter2).map(|(i1,i2)|…)

for (i1,i2) in iter1.zip(iter2) {…}

To iterate more you can nest zip():

for ((i1,i2),i3) in iter1.zip(iter2).zip(iter3) {}

or better, use Itertools::multizip.

iter.zip example: is.gd/5Xq53J

· Web · 4 · 4

@rust Actually I needed it yesterday. I'm going to take a look at iterators soon. I can see that they are interesting.