os-rust/src/test/run-pass/foreach-put-structured.rs

22 lines
342 B
Rust
Raw Normal View History

2010-06-23 21:03:09 -07:00
iter pairs() -> tup(int,int) {
let int i = 0;
let int j = 0;
while (i < 10) {
put tup(i, j);
i += 1;
j += i;
}
}
fn main() {
let int i = 10;
let int j = 0;
for each (tup(int,int) p in pairs()) {
log p._0;
log p._1;
assert (p._0 + 10 == i);
2010-06-23 21:03:09 -07:00
i += 1;
j = p._1;
}
assert (j == 45);
2010-06-23 21:03:09 -07:00
}