@@ -1859,14 +1859,13 @@ pub trait Iterator {
1859
1859
Self : Sized , F : FnMut ( Self :: Item ) -> bool
1860
1860
{
1861
1861
#[ inline]
1862
- fn check < T > ( mut f : impl FnMut ( T ) -> bool ) -> impl FnMut ( T ) -> LoopState < ( ) , ( ) > {
1863
- move |x| {
1862
+ fn check < T > ( mut f : impl FnMut ( T ) -> bool ) -> impl FnMut ( ( ) , T ) -> LoopState < ( ) , ( ) > {
1863
+ move |( ) , x| {
1864
1864
if f ( x) { LoopState :: Continue ( ( ) ) }
1865
1865
else { LoopState :: Break ( ( ) ) }
1866
1866
}
1867
1867
}
1868
-
1869
- self . try_for_each ( check ( f) ) == LoopState :: Continue ( ( ) )
1868
+ self . try_fold ( ( ) , check ( f) ) == LoopState :: Continue ( ( ) )
1870
1869
}
1871
1870
1872
1871
/// Tests if any element of the iterator matches a predicate.
@@ -1913,14 +1912,14 @@ pub trait Iterator {
1913
1912
F : FnMut ( Self :: Item ) -> bool
1914
1913
{
1915
1914
#[ inline]
1916
- fn check < T > ( mut f : impl FnMut ( T ) -> bool ) -> impl FnMut ( T ) -> LoopState < ( ) , ( ) > {
1917
- move |x| {
1915
+ fn check < T > ( mut f : impl FnMut ( T ) -> bool ) -> impl FnMut ( ( ) , T ) -> LoopState < ( ) , ( ) > {
1916
+ move |( ) , x| {
1918
1917
if f ( x) { LoopState :: Break ( ( ) ) }
1919
1918
else { LoopState :: Continue ( ( ) ) }
1920
1919
}
1921
1920
}
1922
1921
1923
- self . try_for_each ( check ( f) ) == LoopState :: Break ( ( ) )
1922
+ self . try_fold ( ( ) , check ( f) ) == LoopState :: Break ( ( ) )
1924
1923
}
1925
1924
1926
1925
/// Searches for an element of an iterator that satisfies a predicate.
@@ -1972,14 +1971,16 @@ pub trait Iterator {
1972
1971
P : FnMut ( & Self :: Item ) -> bool ,
1973
1972
{
1974
1973
#[ inline]
1975
- fn check < T > ( mut predicate : impl FnMut ( & T ) -> bool ) -> impl FnMut ( T ) -> LoopState < ( ) , T > {
1976
- move |x| {
1974
+ fn check < T > (
1975
+ mut predicate : impl FnMut ( & T ) -> bool
1976
+ ) -> impl FnMut ( ( ) , T ) -> LoopState < ( ) , T > {
1977
+ move |( ) , x| {
1977
1978
if predicate ( & x) { LoopState :: Break ( x) }
1978
1979
else { LoopState :: Continue ( ( ) ) }
1979
1980
}
1980
1981
}
1981
1982
1982
- self . try_for_each ( check ( predicate) ) . break_value ( )
1983
+ self . try_fold ( ( ) , check ( predicate) ) . break_value ( )
1983
1984
}
1984
1985
1985
1986
/// Applies function to the elements of iterator and returns
@@ -2004,14 +2005,14 @@ pub trait Iterator {
2004
2005
F : FnMut ( Self :: Item ) -> Option < B > ,
2005
2006
{
2006
2007
#[ inline]
2007
- fn check < T , B > ( mut f : impl FnMut ( T ) -> Option < B > ) -> impl FnMut ( T ) -> LoopState < ( ) , B > {
2008
- move |x| match f ( x) {
2008
+ fn check < T , B > ( mut f : impl FnMut ( T ) -> Option < B > ) -> impl FnMut ( ( ) , T ) -> LoopState < ( ) , B > {
2009
+ move |( ) , x| match f ( x) {
2009
2010
Some ( x) => LoopState :: Break ( x) ,
2010
2011
None => LoopState :: Continue ( ( ) ) ,
2011
2012
}
2012
2013
}
2013
2014
2014
- self . try_for_each ( check ( f) ) . break_value ( )
2015
+ self . try_fold ( ( ) , check ( f) ) . break_value ( )
2015
2016
}
2016
2017
2017
2018
/// Searches for an element in an iterator, returning its index.
0 commit comments