[Pre-RFC] Replace IteratorExt::zip with tuple iteration

I prefer the explicit versions like (a, b, c).zip() or Zip::new((a, b, c)) too.

2 Likes

Yeah, there are at least four ways to interpret (a, b, c).into_iter():

  1. Zip the iterators (original proposal)
  2. Chain the iterators
  3. Cartesian product (@glaebhoerl, Haskell)
  4. Treat the tuple as a slice (@DanielKeep, Python)

Without context, it won't be obvious which of these is being used.

tuple as slice won’t make sense if the type of the tuple elements differs, and would then make sense for all types (even those that don’t implement Iterator.

I now agree that there should be a TupleIterExt that offers .zip() and .prod() for all tuples of types implementing Iterator.

.chain() is special, as it can only exist if the iterators have the same Item type.

:+1: but to have it possible in sane way we need variadic templates.

since this has been delegated to post-1.0 we can wait for variadic generics :slight_smile:

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