File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,6 @@ where
276
276
} ) ;
277
277
278
278
phantom_hints. push ( route_hints) ;
279
-
280
279
}
281
280
282
281
// We have one vector per real node involved in creating the phantom invoice. To distribute
@@ -289,19 +288,18 @@ where
289
288
/// Draw items iteratively from multiple nested vectors. The items are retrieved by index and
290
289
/// rotates through the vectors - first the zero index then the first index then second index, etc.
291
290
fn rotate_nested_vectors < T , I : Iterator < Item = T > > ( mut vecs : Vec < I > ) -> impl Iterator < Item = T > {
292
- let mut idx = 0 ;
291
+ let mut iterations = 0 ;
293
292
294
293
core:: iter:: from_fn ( move || {
295
294
let mut exhausted_vectors = 0 ;
296
295
loop {
297
296
if vecs. is_empty ( ) {
298
297
return None ;
299
298
}
300
- let next_idx = idx % vecs. len ( ) ;
301
- let hint_opt = vecs[ next_idx] . next ( ) ;
302
- idx += 1 ;
303
- if let Some ( hint) = hint_opt {
304
- return Some ( hint) ;
299
+ let next_idx = iterations % vecs. len ( ) ;
300
+ iterations += 1 ;
301
+ if let Some ( item) = vecs[ next_idx] . next ( ) {
302
+ return Some ( item) ;
305
303
}
306
304
// exhausted_vectors increase when the "next_idx" vector is exhausted
307
305
exhausted_vectors += 1 ;
@@ -1915,7 +1913,6 @@ mod test {
1915
1913
}
1916
1914
}
1917
1915
1918
-
1919
1916
#[ test]
1920
1917
fn test_zip_nested_vectors ( ) {
1921
1918
// two nested vectors
You can’t perform that action at this time.
0 commit comments