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 type rect = (Point, Point);
15 fn fst(r: rect) -> Point { let (fst, _) = r; return fst; }
16 fn snd(r: rect) -> Point { let (_, snd) = r; return snd; }
18 fn f(r: rect, x1: int, y1: int, x2: int, y2: int) {
19 assert_eq!(fst(r).x, x1);
20 assert_eq!(fst(r).y, y1);
21 assert_eq!(snd(r).x, x2);
22 assert_eq!(snd(r).y, y2);
26 let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22});
27 assert_eq!(fst(r).x, 10);
28 assert_eq!(fst(r).y, 20);
29 assert_eq!(snd(r).x, 11);
30 assert_eq!(snd(r).y, 22);
32 let x: int = fst(r2).x;
35 f(r2, 10, 20, 11, 22);