1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 struct Point {x: int, y: int}
13 impl Copy for Point {}
15 type rect = (Point, Point);
17 fn fst(r: rect) -> Point { let (fst, _) = r; return fst; }
18 fn snd(r: rect) -> Point { let (_, snd) = r; return snd; }
20 fn f(r: rect, x1: int, y1: int, x2: int, y2: int) {
21 assert_eq!(fst(r).x, x1);
22 assert_eq!(fst(r).y, y1);
23 assert_eq!(snd(r).x, x2);
24 assert_eq!(snd(r).y, y2);
28 let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22});
29 assert_eq!(fst(r).x, 10);
30 assert_eq!(fst(r).y, 20);
31 assert_eq!(snd(r).x, 11);
32 assert_eq!(snd(r).y, 22);
34 let x: int = fst(r2).x;
37 f(r2, 10, 20, 11, 22);