impl ParallelExtend for tuple pairs#604
Merged
bors[bot] merged 1 commit intorayon-rs:masterfrom Oct 30, 2018
Merged
Conversation
`ParallelExtend<(A, B)>` and `ParallelExtend<Either<L, R>>` for tuples behave like `unzip` and `partition_map` respectively. These allow the possibility of nested `unzip` and `partition_map` operations, filling into more than just two collections. For instance, `(A, (B, C))` items can be unzipped into `(Vec<A>, (Vec<B>, Vec<C>))`.
cuviper
commented
Oct 9, 2018
| } | ||
|
|
||
|
|
||
| impl<A, B, FromA, FromB> ParallelExtend<(A, B)> for (FromA, FromB) |
Member
Author
There was a problem hiding this comment.
FWIW, the standard library does not have an Extend implementation like this, though I think it could. The value there would not be as high though, as there's significantly more magic involved in the parallel implementation.
cuviper
commented
Oct 9, 2018
| } | ||
| } | ||
|
|
||
| impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B) |
Member
Author
There was a problem hiding this comment.
I think coherence rules would make this impossible for Extend since tuples aren't fundamental -- the either crate can't implement the trait for a generic tuple type. So this is a unique possibility for ParallelExtend!
Member
Author
There was a problem hiding this comment.
Hmm, Rust 1.41's "re-rebalance coherence" would allow this now... 🤔
nikomatsakis
approved these changes
Oct 30, 2018
Member
|
bors r+ |
bors bot
added a commit
that referenced
this pull request
Oct 30, 2018
604: impl ParallelExtend for tuple pairs r=nikomatsakis a=cuviper `ParallelExtend<(A, B)>` and `ParallelExtend<Either<L, R>>` for tuples behave like `unzip` and `partition_map` respectively. These allow the possibility of nested `unzip` and `partition_map` operations, filling into more than just two collections. For instance, `(A, (B, C))` items can be unzipped into `(Vec<A>, (Vec<B>, Vec<C>))`. Fixes #600. Co-authored-by: Josh Stone <cuviper@gmail.com>
Contributor
This was referenced Sep 17, 2020
bors bot
added a commit
that referenced
this pull request
Apr 1, 2021
802: impl FromParallelIterator for tuple pairs r=nikomatsakis a=cuviper Like #604 for `ParallelExtend`, implementing `FromParallelIterator` for tuple pairs opens up new possibilities for nesting `collect`. The possibility of short-circuiting into `Result<(T, U), E>` for #801 is particularly motivating. - `FromParallelIterator<(A, B)> for (FromA, FromB)` works like `unzip` - `FromParallelIterator<Either<L, R>> for (A, B)` works like `partition_map` Co-authored-by: Josh Stone <cuviper@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ParallelExtend<(A, B)>andParallelExtend<Either<L, R>>for tuplesbehave like
unzipandpartition_maprespectively. These allow thepossibility of nested
unzipandpartition_mapoperations, fillinginto more than just two collections. For instance,
(A, (B, C))itemscan be unzipped into
(Vec<A>, (Vec<B>, Vec<C>)).Fixes #600.