@@ -579,7 +579,7 @@ where
579
579
} ) ?;
580
580
581
581
if is_empty {
582
- return Try :: from_ok ( acc) ;
582
+ return try { acc } ;
583
583
}
584
584
585
585
loop {
@@ -715,7 +715,7 @@ where
715
715
if self . first_take {
716
716
self . first_take = false ;
717
717
match self . iter . next ( ) {
718
- None => return Try :: from_ok ( acc) ,
718
+ None => return try { acc } ,
719
719
Some ( x) => acc = f ( acc, x) ?,
720
720
}
721
721
}
@@ -792,7 +792,7 @@ where
792
792
}
793
793
794
794
match self . next_back ( ) {
795
- None => Try :: from_ok ( init) ,
795
+ None => try { init } ,
796
796
Some ( x) => {
797
797
let acc = f ( init, x) ?;
798
798
from_fn ( nth_back ( & mut self . iter , self . step ) ) . try_fold ( acc, f)
@@ -1075,7 +1075,7 @@ fn filter_try_fold<'a, T, Acc, R: Try<Ok = Acc>>(
1075
1075
predicate : & ' a mut impl FnMut ( & T ) -> bool ,
1076
1076
mut fold : impl FnMut ( Acc , T ) -> R + ' a ,
1077
1077
) -> impl FnMut ( Acc , T ) -> R + ' a {
1078
- move |acc, item| if predicate ( & item) { fold ( acc, item) } else { R :: from_ok ( acc) }
1078
+ move |acc, item| if predicate ( & item) { fold ( acc, item) } else { try { acc } }
1079
1079
}
1080
1080
1081
1081
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1229,7 +1229,7 @@ fn filter_map_try_fold<'a, T, B, Acc, R: Try<Ok = Acc>>(
1229
1229
) -> impl FnMut ( Acc , T ) -> R + ' a {
1230
1230
move |acc, item| match f ( item) {
1231
1231
Some ( x) => fold ( acc, x) ,
1232
- None => R :: from_ok ( acc) ,
1232
+ None => try { acc } ,
1233
1233
}
1234
1234
}
1235
1235
@@ -1660,7 +1660,7 @@ impl<I: Iterator> Iterator for Peekable<I> {
1660
1660
R : Try < Ok = B > ,
1661
1661
{
1662
1662
let acc = match self . peeked . take ( ) {
1663
- Some ( None ) => return Try :: from_ok ( init) ,
1663
+ Some ( None ) => return try { init } ,
1664
1664
Some ( Some ( v) ) => f ( init, v) ?,
1665
1665
None => init,
1666
1666
} ;
@@ -1703,7 +1703,7 @@ where
1703
1703
R : Try < Ok = B > ,
1704
1704
{
1705
1705
match self . peeked . take ( ) {
1706
- Some ( None ) => Try :: from_ok ( init) ,
1706
+ Some ( None ) => try { init } ,
1707
1707
Some ( Some ( v) ) => match self . iter . try_rfold ( init, & mut f) . into_result ( ) {
1708
1708
Ok ( acc) => f ( acc, v) ,
1709
1709
Err ( e) => {
@@ -1938,7 +1938,7 @@ where
1938
1938
if !self . flag {
1939
1939
match self . next ( ) {
1940
1940
Some ( v) => init = fold ( init, v) ?,
1941
- None => return Try :: from_ok ( init) ,
1941
+ None => return try { init } ,
1942
1942
}
1943
1943
}
1944
1944
self . iter . try_fold ( init, fold)
@@ -2065,13 +2065,13 @@ where
2065
2065
ControlFlow :: from_try ( fold ( acc, x) )
2066
2066
} else {
2067
2067
* flag = true ;
2068
- ControlFlow :: Break ( Try :: from_ok ( acc) )
2068
+ ControlFlow :: Break ( try { acc } )
2069
2069
}
2070
2070
}
2071
2071
}
2072
2072
2073
2073
if self . flag {
2074
- Try :: from_ok ( init)
2074
+ try { init }
2075
2075
} else {
2076
2076
let flag = & mut self . flag ;
2077
2077
let p = & mut self . predicate ;
@@ -2180,7 +2180,7 @@ where
2180
2180
let Self { iter, predicate } = self ;
2181
2181
iter. try_fold ( init, |acc, x| match predicate ( x) {
2182
2182
Some ( item) => ControlFlow :: from_try ( fold ( acc, item) ) ,
2183
- None => ControlFlow :: Break ( Try :: from_ok ( acc) ) ,
2183
+ None => ControlFlow :: Break ( try { acc } ) ,
2184
2184
} )
2185
2185
. into_try ( )
2186
2186
}
@@ -2316,7 +2316,7 @@ where
2316
2316
if n > 0 {
2317
2317
// nth(n) skips n+1
2318
2318
if self . iter . nth ( n - 1 ) . is_none ( ) {
2319
- return Try :: from_ok ( init) ;
2319
+ return try { init } ;
2320
2320
}
2321
2321
}
2322
2322
self . iter . try_fold ( init, fold)
@@ -2382,7 +2382,7 @@ where
2382
2382
2383
2383
let n = self . len ( ) ;
2384
2384
if n == 0 {
2385
- Try :: from_ok ( init)
2385
+ try { init }
2386
2386
} else {
2387
2387
self . iter . try_rfold ( init, check ( n, fold) ) . into_try ( )
2388
2388
}
@@ -2509,7 +2509,7 @@ where
2509
2509
}
2510
2510
2511
2511
if self . n == 0 {
2512
- Try :: from_ok ( init)
2512
+ try { init }
2513
2513
} else {
2514
2514
let n = & mut self . n ;
2515
2515
self . iter . try_fold ( init, check ( n, fold) ) . into_try ( )
@@ -2587,11 +2587,11 @@ where
2587
2587
R : Try < Ok = Acc > ,
2588
2588
{
2589
2589
if self . n == 0 {
2590
- Try :: from_ok ( init)
2590
+ try { init }
2591
2591
} else {
2592
2592
let len = self . iter . len ( ) ;
2593
2593
if len > self . n && self . iter . nth_back ( len - self . n - 1 ) . is_none ( ) {
2594
- Try :: from_ok ( init)
2594
+ try { init }
2595
2595
} else {
2596
2596
self . iter . try_rfold ( init, fold)
2597
2597
}
@@ -2687,7 +2687,7 @@ where
2687
2687
mut fold : impl FnMut ( Acc , B ) -> R + ' a ,
2688
2688
) -> impl FnMut ( Acc , T ) -> ControlFlow < Acc , R > + ' a {
2689
2689
move |acc, x| match f ( state, x) {
2690
- None => ControlFlow :: Break ( Try :: from_ok ( acc) ) ,
2690
+ None => ControlFlow :: Break ( try { acc } ) ,
2691
2691
Some ( x) => ControlFlow :: from_try ( fold ( acc, x) ) ,
2692
2692
}
2693
2693
}
@@ -2951,7 +2951,7 @@ where
2951
2951
Ok ( x) => ControlFlow :: from_try ( f ( acc, x) ) ,
2952
2952
Err ( e) => {
2953
2953
* error = Err ( e) ;
2954
- ControlFlow :: Break ( Try :: from_ok ( acc) )
2954
+ ControlFlow :: Break ( try { acc } )
2955
2955
}
2956
2956
} )
2957
2957
. into_try ( )
0 commit comments