2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2015-03-30 13:38:27 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2015-03-26 00:06:52 +00:00
|
|
|
struct Point {x: isize, y: isize}
|
2011-08-15 11:39:45 +00:00
|
|
|
|
2013-01-26 06:46:32 +00:00
|
|
|
type rect = (Point, Point);
|
2011-08-15 11:39:45 +00:00
|
|
|
|
2013-01-26 06:46:32 +00:00
|
|
|
fn fst(r: rect) -> Point { let (fst, _) = r; return fst; }
|
|
|
|
fn snd(r: rect) -> Point { let (_, snd) = r; return snd; }
|
2011-08-15 11:39:45 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn f(r: rect, x1: isize, y1: isize, x2: isize, y2: isize) {
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(fst(r).x, x1);
|
|
|
|
assert_eq!(fst(r).y, y1);
|
|
|
|
assert_eq!(snd(r).x, x2);
|
|
|
|
assert_eq!(snd(r).y, y2);
|
2011-08-15 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-01-26 06:46:32 +00:00
|
|
|
let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22});
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(fst(r).x, 10);
|
|
|
|
assert_eq!(fst(r).y, 20);
|
|
|
|
assert_eq!(snd(r).x, 11);
|
|
|
|
assert_eq!(snd(r).y, 22);
|
2011-08-15 11:39:45 +00:00
|
|
|
let r2 = r;
|
2015-03-26 00:06:52 +00:00
|
|
|
let x: isize = fst(r2).x;
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(x, 10);
|
2011-08-15 11:39:45 +00:00
|
|
|
f(r, 10, 20, 11, 22);
|
|
|
|
f(r2, 10, 20, 11, 22);
|
|
|
|
}
|