We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5850f0b commit d33cc12Copy full SHA for d33cc12
src/libcore/tests/iter.rs
@@ -161,6 +161,24 @@ fn test_iterator_step_by() {
161
assert_eq!(it.next(), None);
162
}
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
182
#[test]
183
#[should_panic]
184
fn test_iterator_step_by_zero() {
0 commit comments