Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Itertools::multiunzip #565

Merged
merged 3 commits into from Aug 15, 2021
Merged

Conversation

Veykril
Copy link
Contributor

@Veykril Veykril commented Jul 24, 2021

Simple implementation of Iterator::unzip but for tuples of sizes 0-12.

This requires adding a new public trait to be able to express the dependency between the iterator item tuple to the collection output tuple. But given that a multiunzip function is added to the Itertools trait the MultiUnzip trait does not have to be imported to make use of this.

Another option would be a macro but that would require giving it some extra syntax to declare the arity/return type which seems suboptimal, while this approach just works as a method call akin to std's iterator unzip.

Closes #362

Copy link
Member

@phimuemue phimuemue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there, thanks for this! I would be willing to see this functionality in itertools.

I really like how you mimic unzip's inner workings as far as possible, and document where this is not yet possible.

src/unziptuple.rs Outdated Show resolved Hide resolved
src/unziptuple.rs Outdated Show resolved Hide resolved
src/unziptuple.rs Show resolved Hide resolved
src/unziptuple.rs Show resolved Hide resolved
src/unziptuple.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
tests/test_std.rs Outdated Show resolved Hide resolved
@phimuemue
Copy link
Member

lgtm.

@jswrenn If there are no objections, I'd consider merging, as this is a counterpart to the existing multizip, and it does its job - as far as I can see - reasonably well, considering the circumstances of stable rust.

@phimuemue
Copy link
Member

Thanks for this.

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 15, 2021

Build succeeded:

@bors bors bot merged commit fa3fffb into rust-itertools:master Aug 15, 2021
@Veykril Veykril deleted the multiunzip branch August 15, 2021 19:50
@jswrenn jswrenn added this to the next milestone Sep 13, 2021
@multimeric multimeric mentioned this pull request Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multizip equivalent for unzip
3 participants