1
- use crate :: cmp:: Ordering ;
2
1
use crate :: iter:: adapters:: zip:: try_get_unchecked;
3
2
use crate :: iter:: adapters:: { SourceIter , TrustedRandomAccess , TrustedRandomAccessNoCoerce } ;
4
3
use crate :: iter:: { FusedIterator , InPlaceIterable , TrustedLen } ;
@@ -49,35 +48,20 @@ where
49
48
50
49
fn next_chunk < const N : usize > (
51
50
& mut self ,
52
- ) -> Result < [ Self :: Item ; N ] , array:: IntoIter < Self :: Item , N > > {
51
+ ) -> Result < [ Self :: Item ; N ] , array:: IntoIter < Self :: Item , N > >
52
+ where
53
+ Self : Sized ,
54
+ {
53
55
<I as SpecNextChunk < ' _ , N , T > >:: spec_next_chunk ( & mut self . it )
54
56
}
55
57
56
- #[ inline]
57
58
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
58
59
self . it . size_hint ( )
59
60
}
60
61
61
- #[ inline]
62
- fn count ( self ) -> usize {
63
- self . it . count ( )
64
- }
65
-
66
- fn last ( self ) -> Option < T > {
67
- self . it . last ( ) . copied ( )
68
- }
69
-
70
- #[ inline]
71
- fn advance_by ( & mut self , n : usize ) -> Result < ( ) , NonZero < usize > > {
72
- self . it . advance_by ( n)
73
- }
74
-
75
- fn nth ( & mut self , n : usize ) -> Option < T > {
76
- self . it . nth ( n) . copied ( )
77
- }
78
-
79
62
fn try_fold < B , F , R > ( & mut self , init : B , f : F ) -> R
80
63
where
64
+ Self : Sized ,
81
65
F : FnMut ( B , Self :: Item ) -> R ,
82
66
R : Try < Output = B > ,
83
67
{
@@ -91,56 +75,21 @@ where
91
75
self . it . fold ( init, copy_fold ( f) )
92
76
}
93
77
94
- fn find < P > ( & mut self , mut predicate : P ) -> Option < Self :: Item >
95
- where
96
- P : FnMut ( & Self :: Item ) -> bool ,
97
- {
98
- self . it . find ( move |x| predicate ( & x) ) . copied ( )
99
- }
100
-
101
- fn max_by < F > ( self , mut compare : F ) -> Option < Self :: Item >
102
- where
103
- F : FnMut ( & Self :: Item , & Self :: Item ) -> Ordering ,
104
- {
105
- self . it . max_by ( move |& x, & y| compare ( x, y) ) . copied ( )
106
- }
107
-
108
- fn min_by < F > ( self , mut compare : F ) -> Option < Self :: Item >
109
- where
110
- F : FnMut ( & Self :: Item , & Self :: Item ) -> Ordering ,
111
- {
112
- self . it . min_by ( move |& x, & y| compare ( x, y) ) . copied ( )
113
- }
114
-
115
- fn cmp < O > ( self , other : O ) -> Ordering
116
- where
117
- O : IntoIterator < Item = Self :: Item > ,
118
- Self :: Item : Ord ,
119
- {
120
- self . it . cmp_by ( other, |x, y| x. cmp ( & y) )
78
+ fn nth ( & mut self , n : usize ) -> Option < T > {
79
+ self . it . nth ( n) . copied ( )
121
80
}
122
81
123
- fn partial_cmp < O > ( self , other : O ) -> Option < Ordering >
124
- where
125
- O : IntoIterator ,
126
- Self :: Item : PartialOrd < O :: Item > ,
127
- {
128
- self . it . partial_cmp_by ( other, |x, y| x. partial_cmp ( & y) )
82
+ fn last ( self ) -> Option < T > {
83
+ self . it . last ( ) . copied ( )
129
84
}
130
85
131
- fn eq < O > ( self , other : O ) -> bool
132
- where
133
- O : IntoIterator ,
134
- Self :: Item : PartialEq < O :: Item > ,
135
- {
136
- self . it . eq_by ( other, |x, y| x == & y)
86
+ fn count ( self ) -> usize {
87
+ self . it . count ( )
137
88
}
138
89
139
- fn is_sorted_by < F > ( self , mut compare : F ) -> bool
140
- where
141
- F : FnMut ( & Self :: Item , & Self :: Item ) -> bool ,
142
- {
143
- self . it . is_sorted_by ( move |& x, & y| compare ( x, y) )
90
+ #[ inline]
91
+ fn advance_by ( & mut self , n : usize ) -> Result < ( ) , NonZero < usize > > {
92
+ self . it . advance_by ( n)
144
93
}
145
94
146
95
unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> T
@@ -163,13 +112,9 @@ where
163
112
self . it . next_back ( ) . copied ( )
164
113
}
165
114
166
- #[ inline]
167
- fn advance_back_by ( & mut self , n : usize ) -> Result < ( ) , NonZero < usize > > {
168
- self . it . advance_back_by ( n)
169
- }
170
-
171
115
fn try_rfold < B , F , R > ( & mut self , init : B , f : F ) -> R
172
116
where
117
+ Self : Sized ,
173
118
F : FnMut ( B , Self :: Item ) -> R ,
174
119
R : Try < Output = B > ,
175
120
{
@@ -183,11 +128,9 @@ where
183
128
self . it . rfold ( init, copy_fold ( f) )
184
129
}
185
130
186
- fn rfind < P > ( & mut self , mut predicate : P ) -> Option < Self :: Item >
187
- where
188
- P : FnMut ( & Self :: Item ) -> bool ,
189
- {
190
- self . it . rfind ( move |x| predicate ( & x) ) . copied ( )
131
+ #[ inline]
132
+ fn advance_back_by ( & mut self , n : usize ) -> Result < ( ) , NonZero < usize > > {
133
+ self . it . advance_back_by ( n)
191
134
}
192
135
}
193
136
@@ -197,12 +140,10 @@ where
197
140
I : ExactSizeIterator < Item = & ' a T > ,
198
141
T : Copy ,
199
142
{
200
- #[ inline]
201
143
fn len ( & self ) -> usize {
202
144
self . it . len ( )
203
145
}
204
146
205
- #[ inline]
206
147
fn is_empty ( & self ) -> bool {
207
148
self . it . is_empty ( )
208
149
}
0 commit comments