-
Notifications
You must be signed in to change notification settings - Fork 501
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
partition_map
with a fallible closure - how to shortcircuit?
#801
Comments
I think you could do this today by mimicking Lines 88 to 132 in 4a26ac4
Your
That's controlled by Lines 388 to 391 in 4a26ac4
edit: but you're right, A while ago, I was also experimenting with various #721 is somewhat related too. |
See #802, if you'd like to try it out... |
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]>
I am trying to do something like the code below which works fine if I choose to ignore the
Err
coming out offallible_calculation
. However, I do not know how to short-circuit the calculation and turn(Vec<T>, Vec<U>)
intoResult<(Vec<T>, Vec<U>), E>
.How would I go about properly handling the error case? In the case of the
map
adapter the issue is pretty straight forward, but I don't see how can be done in this case, other than maybe collecting to a(Vec<T>, Result<Vec<U>, E>>)
instead, which however doesn't seem to short circuit? That would look like so:Are there better ways?
EDIT: I didn't realize that
Result<T, E>
doesn't implementDefault
andParallelExtend
, which means that this tactic unfortunately doesn't work either. :-(EDIT: The fix that I could come up with to make this workable at all (albeit without short-circuiting) is this:
It's not particularly elegant, but works.
The text was updated successfully, but these errors were encountered: