PageRenderTime 39ms CodeModel.GetById 27ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/test/run-pass/foreach-nested.rs

http://github.com/jruderman/rust
Rust | 17 lines | 12 code | 4 blank | 1 comment | 4 complexity | 5c7753c8dcd6bded0f3490ac3aa6ad87 MD5 | raw file
 1
 2
 3
 4// -*- rust -*-
 5fn two(it: fn(int)) { it(0); it(1); }
 6
 7fn main() {
 8    let a: ~[mut int] = ~[mut -1, -1, -1, -1];
 9    let mut p: int = 0;
10    do two |i| {
11        do two |j| { a[p] = 10 * i + j; p += 1; }
12    }
13    assert (a[0] == 0);
14    assert (a[1] == 1);
15    assert (a[2] == 10);
16    assert (a[3] == 11);
17}