@@ -370,8 +370,7 @@ pub trait ParallelIterator: Sized + Send {
370
370
where OP : Fn ( Self :: Item ) -> R + Sync + Send ,
371
371
R : Try < Ok = ( ) > + Send
372
372
{
373
- self . try_fold_with ( ( ) , move |( ) , x| op ( x) )
374
- . try_reduce ( || ( ) , |( ) , ( ) | R :: from_ok ( ( ) ) )
373
+ self . map ( op) . try_reduce ( || ( ) , |( ) , ( ) | R :: from_ok ( ( ) ) )
375
374
}
376
375
377
376
/// TODO
@@ -715,13 +714,8 @@ pub trait ParallelIterator: Sized + Send {
715
714
<Self :: Item as Try >:: Ok : Send ,
716
715
<Self :: Item as Try >:: Error : Send
717
716
{
718
- let result = self . try_fold (
719
- || None ,
720
- |opt_a, try_b| match ( opt_a, try_b. into_result ( ) ) {
721
- ( Some ( a) , Ok ( b) ) => op ( a, b) . into_result ( ) . map ( Some ) ,
722
- ( _, res_b) => res_b. map ( Some ) ,
723
- } ,
724
- ) . try_reduce (
717
+ // Map into `Result<Option<Ok>, Error>`, then reduce it.
718
+ let result = self . map ( |try_b| try_b. into_result ( ) . map ( Some ) ) . try_reduce (
725
719
|| None ,
726
720
|opt_a, opt_b| match ( opt_a, opt_b) {
727
721
( Some ( a) , Some ( b) ) => op ( a, b) . into_result ( ) . map ( Some ) ,
@@ -730,6 +724,7 @@ pub trait ParallelIterator: Sized + Send {
730
724
} ,
731
725
) ;
732
726
727
+ // Map `Result<Option<Ok>, Error>` back to `Option<Self::Item>`.
733
728
match result {
734
729
Ok ( None ) => None ,
735
730
Ok ( Some ( v) ) => Some ( Self :: Item :: from_ok ( v) ) ,
0 commit comments