-
Notifications
You must be signed in to change notification settings - Fork 565
impl ParallelExtend for tuple pairs #604
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
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>))`.
| } | ||
|
|
||
|
|
||
| impl<A, B, FromA, FromB> ParallelExtend<(A, B)> for (FromA, FromB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| } | ||
| } | ||
|
|
||
| impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, Rust 1.41's "re-rebalance coherence" would allow this now... 🤔
|
bors r+ |
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 <[email protected]>
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 <[email protected]>
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.