PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/swap-2.rs

http://github.com/jruderman/rust
Rust | 12 lines | 11 code | 1 blank | 0 comment | 4 complexity | 722520534e1c7e9ee99a2b710fda304d MD5 | raw file
 1fn swap<T>(v: ~[mut T], i: int, j: int) { v[i] <-> v[j]; }
 2
 3fn main() {
 4    let a: ~[mut int] = ~[mut 0, 1, 2, 3, 4, 5, 6];
 5    swap(a, 2, 4);
 6    assert (a[2] == 4);
 7    assert (a[4] == 2);
 8    let mut n = 42;
 9    n <-> a[0];
10    assert (a[0] == 42);
11    assert (n == 0);
12}