2010-06-23 23:03:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
// -*- rust -*-
|
2012-08-01 19:30:05 -05:00
|
|
|
fn id<T: copy>(x: T) -> T { return x; }
|
2010-06-23 23:03:09 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
type triple = {x: int, y: int, z: int};
|
2010-06-23 23:03:09 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
fn main() {
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut x = 62;
|
|
|
|
let mut y = 63;
|
2011-07-27 07:19:39 -05:00
|
|
|
let a = 'a';
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut b = 'b';
|
2011-07-27 07:19:39 -05:00
|
|
|
let p: triple = {x: 65, y: 66, z: 67};
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut q: triple = {x: 68, y: 69, z: 70};
|
2011-08-13 02:10:18 -05:00
|
|
|
y = id::<int>(x);
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, y);
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x == y);
|
2011-08-13 02:10:18 -05:00
|
|
|
b = id::<char>(a);
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, b);
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (a == b);
|
2011-08-13 02:10:18 -05:00
|
|
|
q = id::<triple>(p);
|
2011-07-26 07:49:40 -05:00
|
|
|
x = p.z;
|
|
|
|
y = q.z;
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, y);
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x == y);
|
2011-08-12 08:37:25 -05:00
|
|
|
}
|