@@ -138,45 +138,51 @@ where
138
138
fn count ( self ) -> usize {
139
139
match self . 0 {
140
140
ProductEnded => 0 ,
141
- ProductInProgress ( MultiProductInner { iters , cur } ) => {
142
- if cur . is_none ( ) {
143
- // The iterator is fresh so the count is the product of the length of each iterator:
144
- // - If one of them is empty, stop counting.
145
- // - Less `count()` calls than the general case.
146
- iters
147
- . into_iter ( )
148
- . map ( |iter| iter . iter_orig . count ( ) )
149
- . try_fold ( 1 , |product , count| {
150
- if count == 0 {
151
- None
152
- } else {
153
- Some ( product * count )
154
- }
155
- } )
156
- . unwrap_or_default ( )
157
- } else {
158
- // The general case.
159
- iters . into_iter ( ) . fold ( 0 , | mut acc , iter| {
160
- if acc != 0 {
161
- acc *= iter . iter_orig . count ( ) ;
162
- }
163
- acc + iter . iter . count ( )
164
- } )
141
+ // The iterator is fresh so the count is the product of the length of each iterator:
142
+ // - If one of them is empty, stop counting.
143
+ // - Less ` count()` calls than the general case.
144
+ ProductInProgress ( MultiProductInner {
145
+ iters ,
146
+ cur : NotYetPopulated ,
147
+ } ) => iters
148
+ . into_iter ( )
149
+ . map ( |iter| iter . iter_orig . count ( ) )
150
+ . try_fold ( 1 , |product , count| {
151
+ if count == 0 {
152
+ None
153
+ } else {
154
+ Some ( product * count )
155
+ }
156
+ } )
157
+ . unwrap_or_default ( ) ,
158
+ // The general case.
159
+ ProductInProgress ( MultiProductInner {
160
+ iters ,
161
+ cur : Populated ( _ ) ,
162
+ } ) => iters . into_iter ( ) . fold ( 0 , | mut acc , iter| {
163
+ if acc != 0 {
164
+ acc *= iter . iter_orig . count ( ) ;
165
165
}
166
- }
166
+ acc + iter. iter . count ( )
167
+ } ) ,
167
168
}
168
169
}
169
170
170
171
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
171
172
match & self . 0 {
172
173
ProductEnded => ( 0 , Some ( 0 ) ) ,
173
- ProductInProgress ( MultiProductInner { iters, cur } ) => {
174
- if cur. is_none ( ) {
175
- iters
176
- . iter ( )
177
- . map ( |iter| iter. iter_orig . size_hint ( ) )
178
- . fold ( ( 1 , Some ( 1 ) ) , size_hint:: mul)
179
- } else if let [ first, tail @ ..] = & iters[ ..] {
174
+ ProductInProgress ( MultiProductInner {
175
+ iters,
176
+ cur : NotYetPopulated ,
177
+ } ) => iters
178
+ . iter ( )
179
+ . map ( |iter| iter. iter_orig . size_hint ( ) )
180
+ . fold ( ( 1 , Some ( 1 ) ) , size_hint:: mul) ,
181
+ ProductInProgress ( MultiProductInner {
182
+ iters,
183
+ cur : Populated ( _) ,
184
+ } ) => {
185
+ if let [ first, tail @ ..] = & iters[ ..] {
180
186
tail. iter ( ) . fold ( first. iter . size_hint ( ) , |mut sh, iter| {
181
187
sh = size_hint:: mul ( sh, iter. iter_orig . size_hint ( ) ) ;
182
188
size_hint:: add ( sh, iter. iter . size_hint ( ) )
0 commit comments