@@ -65,12 +65,11 @@ pub trait Formula1<O: ThermodynamicQuantity, I1: ThermodynamicQuantity> {
6565 {
6666 let i1: ArrayView < I1 , D > = i1. into ( ) ;
6767
68- Zip :: from ( i1)
69- . fold_while ( Ok ( ( ) ) , |_, & a| match Self :: validate_inputs ( a) {
70- Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
71- Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
72- } )
73- . into_inner ( ) ?;
68+ Zip :: from ( i1) . par_fold (
69+ || Ok ( ( ) ) ,
70+ |_, & i1| Self :: validate_inputs ( i1) ,
71+ |a, b| a. and ( b) ,
72+ ) ?;
7473
7574 Ok ( Zip :: from ( i1) . par_map_collect ( |& a| Self :: compute_unchecked ( a) ) )
7675 }
@@ -119,11 +118,9 @@ pub trait Formula2<O: ThermodynamicQuantity, I1: ThermodynamicQuantity, I2: Ther
119118
120119 Zip :: from ( i1)
121120 . and ( i2)
122- . fold_while ( Ok ( ( ) ) , |_, & i1, & i2| {
123- match Self :: validate_inputs ( i1, i2) {
124- Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
125- Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
126- }
121+ . fold_while ( Ok ( ( ) ) , |_, & i1, & i2| match Self :: validate_inputs ( i1, i2) {
122+ Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
123+ Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
127124 } )
128125 . into_inner ( ) ?;
129126
@@ -157,15 +154,11 @@ pub trait Formula2<O: ThermodynamicQuantity, I1: ThermodynamicQuantity, I2: Ther
157154 let i1: ArrayView < I1 , D > = i1. into ( ) ;
158155 let i2: ArrayView < I2 , D > = i2. into ( ) ;
159156
160- Zip :: from ( i1)
161- . and ( i2)
162- . fold_while ( Ok ( ( ) ) , |_, & i1, & i2| {
163- match Self :: validate_inputs ( i1, i2) {
164- Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
165- Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
166- }
167- } )
168- . into_inner ( ) ?;
157+ Zip :: from ( i1) . and ( i2) . par_fold (
158+ || Ok ( ( ) ) ,
159+ |_, & i1, & i2| Self :: validate_inputs ( i1, i2) ,
160+ |a, b| a. and ( b) ,
161+ ) ?;
169162
170163 Ok ( Zip :: from ( i1)
171164 . and ( i2)
@@ -228,13 +221,12 @@ pub trait Formula3<
228221 Zip :: from ( i1)
229222 . and ( i2)
230223 . and ( i3)
231- . fold_while (
232- Ok ( ( ) ) ,
233- |_, & i1, & i2, & i3| match Self :: validate_inputs ( i1, i2, i3) {
224+ . fold_while ( Ok ( ( ) ) , |_, & i1, & i2, & i3| {
225+ match Self :: validate_inputs ( i1, i2, i3) {
234226 Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
235227 Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
236- } ,
237- )
228+ }
229+ } )
238230 . into_inner ( ) ?;
239231
240232 Ok ( Zip :: from ( i1)
@@ -273,17 +265,11 @@ pub trait Formula3<
273265 let i2: ArrayView < I2 , D > = i2. into ( ) ;
274266 let i3: ArrayView < I3 , D > = i3. into ( ) ;
275267
276- Zip :: from ( i1)
277- . and ( i2)
278- . and ( i3)
279- . fold_while (
280- Ok ( ( ) ) ,
281- |_, & i1, & i2, & i3| match Self :: validate_inputs ( i1, i2, i3) {
282- Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
283- Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
284- } ,
285- )
286- . into_inner ( ) ?;
268+ Zip :: from ( i1) . and ( i2) . and ( i3) . par_fold (
269+ || Ok ( ( ) ) ,
270+ |_, & i1, & i2, & i3| Self :: validate_inputs ( i1, i2, i3) ,
271+ |a, b| a. and ( b) ,
272+ ) ?;
287273
288274 Ok ( Zip :: from ( i1)
289275 . and ( i2)
@@ -410,18 +396,11 @@ pub trait Formula4<
410396 let i3: ArrayView < I3 , D > = i3. into ( ) ;
411397 let i4: ArrayView < I4 , D > = i4. into ( ) ;
412398
413- Zip :: from ( i1)
414- . and ( i2)
415- . and ( i3)
416- . and ( i4)
417- . fold_while (
418- Ok ( ( ) ) ,
419- |_, & i1, & i2, & i3, & i4| match Self :: validate_inputs ( i1, i2, i3, i4) {
420- Ok ( _) => FoldWhile :: Continue ( Ok ( ( ) ) ) ,
421- Err ( e) => FoldWhile :: Done ( Err ( e) ) ,
422- } ,
423- )
424- . into_inner ( ) ?;
399+ Zip :: from ( i1) . and ( i2) . and ( i3) . and ( i4) . par_fold (
400+ || Ok ( ( ) ) ,
401+ |_, & i1, & i2, & i3, & i4| Self :: validate_inputs ( i1, i2, i3, i4) ,
402+ |a, b| a. and ( b) ,
403+ ) ?;
425404
426405 Ok ( Zip :: from ( i1)
427406 . and ( i2)
0 commit comments