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

impl IntoParallelIterator for tuples => MultiZip #711

Merged
merged 3 commits into from
Dec 18, 2019

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Dec 5, 2019

This is implemented for tuples up to arity 12, much like the standard
library's trait implementations.

  • For (a, b, ...), it calls into_par_iter() on each member.
  • For &(a, b, ...), it calls par_iter() on each member.
  • For &mut (a, b, ...), it calls par_iter_mut() on each member.

The resulting MultiZip iterator returns a tuple of the zipped items
from each input iterator. Internally, it is implemented with macros that
forward to a series of regular zips, mapping to a flattened tuple.

Closes #567.

This is implemented for tuples up to arity 12, much like the standard
library's trait implementations.

- For `(a, b, ...)`, it calls `into_par_iter()` on each member.
- For `&(a, b, ...)`, it calls `par_iter()` on each member.
- For `&mut (a, b, ...)`, it calls `par_iter_mut()` on each member.

The resulting `MultiZip` iterator returns a tuple of the zipped items
from each input iterator. Internally, it is implemented with macros that
forward to a series of regular `zip`s, mapping to a flattened tuple.
@cuviper cuviper changed the title impl IntoIterator for tuples => MultiZip impl IntoParallelIterator for tuples => MultiZip Dec 5, 2019
@nikomatsakis
Copy link
Member

My obvious hesitation is that this goes beyond the surface area of libstd. But I think it makes a lot of sense to have IntoParallelIterator on tuples and zipping is the obvious meaning.

Copy link
Member

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Code looks very good. r=me

@nikomatsakis
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Dec 18, 2019
711: impl IntoParallelIterator for tuples => MultiZip r=nikomatsakis a=cuviper

This is implemented for tuples up to arity 12, much like the standard
library's trait implementations.

- For `(a, b, ...)`, it calls `into_par_iter()` on each member.
- For `&(a, b, ...)`, it calls `par_iter()` on each member.
- For `&mut (a, b, ...)`, it calls `par_iter_mut()` on each member.

The resulting `MultiZip` iterator returns a tuple of the zipped items
from each input iterator. Internally, it is implemented with macros that
forward to a series of regular `zip`s, mapping to a flattened tuple.

Closes #567.

Co-authored-by: Josh Stone <cuviper@gmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 18, 2019

Build failed

@cuviper
Copy link
Member Author

cuviper commented Dec 18, 2019

It seems windows-gnu is broken: rust-lang/rust#67408

bors bot added a commit that referenced this pull request Dec 18, 2019
714: Reduce Windows CI to just stable Rust r=cuviper a=cuviper

CI for #711 ran into a broken beta windows-gnu toolchain, which is frustrating, but in general I already feel that it's overkill to test so much on Windows. The Linux builds on Travis CI already test a breadth of compiler versions, and it does so in parallel, whereas Appveyor runs serially. We can just test Windows stable to be sure the platform works at all, and leave it at that.

Co-authored-by: Josh Stone <cuviper@gmail.com>
@cuviper
Copy link
Member Author

cuviper commented Dec 18, 2019

bors retry

bors bot added a commit that referenced this pull request Dec 18, 2019
711: impl IntoParallelIterator for tuples => MultiZip r=nikomatsakis a=cuviper

This is implemented for tuples up to arity 12, much like the standard
library's trait implementations.

- For `(a, b, ...)`, it calls `into_par_iter()` on each member.
- For `&(a, b, ...)`, it calls `par_iter()` on each member.
- For `&mut (a, b, ...)`, it calls `par_iter_mut()` on each member.

The resulting `MultiZip` iterator returns a tuple of the zipped items
from each input iterator. Internally, it is implemented with macros that
forward to a series of regular `zip`s, mapping to a flattened tuple.

Closes #567.

Co-authored-by: Josh Stone <cuviper@gmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 18, 2019

@bors bors bot merged commit c0dd154 into rayon-rs:master Dec 18, 2019
@cuviper cuviper deleted the multizip branch March 11, 2020 23:48
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.

Support for Zipping multiple array
2 participants