/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. // -*- rust -*-
  2. type rect = {x: int, y: int, w: int, h: int};
  3. fn f(r: rect, x: int, y: int, w: int, h: int) {
  4. assert (r.x == x);
  5. assert (r.y == y);
  6. assert (r.w == w);
  7. assert (r.h == h);
  8. }
  9. fn main() {
  10. let r: rect = {x: 10, y: 20, w: 100, h: 200};
  11. assert (r.x == 10);
  12. assert (r.y == 20);
  13. assert (r.w == 100);
  14. assert (r.h == 200);
  15. let r2: rect = r;
  16. let x: int = r2.x;
  17. assert (x == 10);
  18. f(r, 10, 20, 100, 200);
  19. f(r2, 10, 20, 100, 200);
  20. }