Repository navigation
Consider tuple iteration #930
Description
Activity
It doesn't really need to be syntax sugar. If it's done as an IntoIterator impl on tuples then it's not exactly syntax, is it?
I've written code like:
for (bx, (by, bz)) in xs.iter().zip(ys.iter().zip(zs.iter_mut())) { }too many times. This would be much appreciated and make iterating over several iterables at once far easier to read, in my opinion.
Reacted by Paul HilscherI would love to see this. Zip syntax right now is kind of ugly and unreadable, IMHO. I almost prefer to use indices instead of iterators half the time. I don't think there's any reason why we couldn't have both.
See #1650 which presents one way to do this.
- addedT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.T-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]
on Aug 25, 2016 I'm not really sure I see how that would make this possible. I'm just looking for an impl of
IntoIteratorfor the tuples where every element implementsIntoIteratorthat behaves somewhat likezipdoes.That is,
for x in (&[1, 2, 3], &[4, 5, 6]) { println!("{:?}", x); }
would be equivalent to
for x in (&[1,2,3]).into_iter().zip(&[4,5,6]) { println!("{:?}", x); }
Ah sorry, I misunderstood what you were asking for. What I had in mind was somelike like a
mapoperation that you could perform on each element of a tuple, even if they have different types.Reacted by Muhammad N ElNokrashyShould rust-lang/rust#43242 be part of this RFC or a separate one?
- addedT-libsRelevant to the library team, which will review and decide on the RFC.Relevant to the library team, which will review and decide on the RFC.and removedT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]
on Aug 18, 2026
Original proposed in #870, some syntax sugar for iterating over multiple things.