PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/src/test/run-pass/rec.rs

http://github.com/jruderman/rust
Rust | 25 lines | 19 code | 5 blank | 1 comment | 9 complexity | 1249fa449ee0b5594c2ccc5f835dfa53 MD5 | raw file
 1
 2
 3
 4// -*- rust -*-
 5type rect = {x: int, y: int, w: int, h: int};
 6
 7fn f(r: rect, x: int, y: int, w: int, h: int) {
 8    assert (r.x == x);
 9    assert (r.y == y);
10    assert (r.w == w);
11    assert (r.h == h);
12}
13
14fn main() {
15    let r: rect = {x: 10, y: 20, w: 100, h: 200};
16    assert (r.x == 10);
17    assert (r.y == 20);
18    assert (r.w == 100);
19    assert (r.h == 200);
20    let r2: rect = r;
21    let x: int = r2.x;
22    assert (x == 10);
23    f(r, 10, 20, 100, 200);
24    f(r2, 10, 20, 100, 200);
25}