rust/src/test/run-pass/iter-eachi.rs

19 lines
325 B
Rust
Raw Normal View History

fn main() {
let mut c = 0u;
2012-10-09 23:28:04 -05:00
for [1u, 2u, 3u, 4u, 5u].eachi |i, v| {
assert (i + 1u) == *v;
c += 1u;
}
assert c == 5u;
2012-08-20 14:23:37 -05:00
for None::<uint>.eachi |i, v| { fail; }
let mut c = 0u;
2012-08-20 14:23:37 -05:00
for Some(1u).eachi |i, v| {
assert (i + 1u) == *v;
c += 1u;
}
assert c == 1u;
}