File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,24 @@ fn test_iterator_step_by() {
161
161
assert_eq ! ( it. next( ) , None ) ;
162
162
}
163
163
164
+ #[ test]
165
+ fn test_iterator_step_by_nth ( ) {
166
+ let mut it = ( 0 ..16 ) . step_by ( 5 ) ;
167
+ assert_eq ! ( it. nth( 0 ) , Some ( 0 ) ) ;
168
+ assert_eq ! ( it. nth( 0 ) , Some ( 5 ) ) ;
169
+ assert_eq ! ( it. nth( 0 ) , Some ( 10 ) ) ;
170
+ assert_eq ! ( it. nth( 0 ) , Some ( 15 ) ) ;
171
+ assert_eq ! ( it. nth( 0 ) , None ) ;
172
+
173
+ let it = ( 0 ..18 ) . step_by ( 5 ) ;
174
+ assert_eq ! ( it. clone( ) . nth( 0 ) , Some ( 0 ) ) ;
175
+ assert_eq ! ( it. clone( ) . nth( 1 ) , Some ( 5 ) ) ;
176
+ assert_eq ! ( it. clone( ) . nth( 2 ) , Some ( 10 ) ) ;
177
+ assert_eq ! ( it. clone( ) . nth( 3 ) , Some ( 15 ) ) ;
178
+ assert_eq ! ( it. clone( ) . nth( 4 ) , None ) ;
179
+ assert_eq ! ( it. clone( ) . nth( 42 ) , None ) ;
180
+ }
181
+
164
182
#[ test]
165
183
#[ should_panic]
166
184
fn test_iterator_step_by_zero ( ) {
You can’t perform that action at this time.
0 commit comments