3 ms·
> (except the obvious `:Vec<_>` type that is not required) It is required, otherwise, `collect()` doesn't know what type of collection to collect into. > It
by steveklabnik 10y ago
> (except the obvious `:Vec<_>` type that is not required)
It is required, otherwise, `collect()` doesn't know what type of collection to collect into.
> It may be possible to implement `.zipped` on tuples though.
This is impossible without varargs, no?
- pcwalton 10y ago> This is impossible without varargs, no? Nah, you'd just implement it as an impl over and over on tuples of reasonable size (up to 16 or so). It wouldn't be elegant, but it'd work in practice.
- steveklabnik 10y agoOh right, I see now.
- __s 10y agoThis technique is used a lot by specs: https://github.com/slide-rs/specs/blob/master/src/join.rs#L50 https://github.com/slide-rs/specs/blob/master/src/join.rs#L5...
- cbreeden 10y agoWhich is what itertools does I believe https://bluss.github.io/rust-itertools/doc/itertools/struct.Zip.html https://bluss.github.io/rust-itertools/doc/itertools/struct....
- nercury 10y ago> `collect()` doesn't know what type of collection to collect into. Yes, unless there is some other mention of Vec, i.e. it is returned from the function. > This is impossible without varargs, no? Varargs would definitely help, and would allow Rust to borrow more ideas without workarounds. But one can do it manually for each tuple variant.
- nimish 10y agoHaskell just brute force implements zipWith3, zipWith4 etc Not elegant, but it works.
- tome 10y agoThe un brute force way is to use the Applicative instance of ZipList.