92
92
I :: Item : Clone ,
93
93
{
94
94
type Item = Vec < I :: Item > ;
95
+
95
96
fn next ( & mut self ) -> Option < Self :: Item > {
96
97
// If this is the first iteration, return early
97
98
if self . first {
@@ -105,32 +106,11 @@ where
105
106
} ;
106
107
}
107
108
108
- // Check if we need to consume more from the iterator
109
- // This will run while we increment our first index digit
110
- self . pool . get_next ( ) ;
111
-
112
- // Work out where we need to update our indices
113
- let mut increment: Option < ( usize , usize ) > = None ;
114
- for ( i, indices_int) in self . indices . iter ( ) . enumerate ( ) . rev ( ) {
115
- if * indices_int < self . pool . len ( ) - 1 {
116
- increment = Some ( ( i, indices_int + 1 ) ) ;
117
- break ;
118
- }
109
+ if self . increment_indices ( ) {
110
+ return None ;
119
111
}
120
112
121
- match increment {
122
- // If we can update the indices further
123
- Some ( ( increment_from, increment_value) ) => {
124
- // We need to update the rightmost non-max value
125
- // and all those to the right
126
- for indices_index in increment_from..self . indices . len ( ) {
127
- self . indices [ indices_index] = increment_value;
128
- }
129
- Some ( self . pool . get_at ( & self . indices ) )
130
- }
131
- // Otherwise, we're done
132
- None => None ,
133
- }
113
+ Some ( self . pool . get_at ( & self . indices ) )
134
114
}
135
115
136
116
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
0 commit comments