rust/src/test/run-pass/generic-fn.rs

33 lines
414 B
Rust
Raw Normal View History

2010-06-23 23:03:09 -05:00
// -*- rust -*-
fn id[T](&T x) -> T {
2010-06-23 23:03:09 -05:00
ret x;
}
type triple = tup(int,int,int);
fn main() {
auto x = 62;
auto y = 63;
auto a = 'a';
auto b = 'b';
let triple p = tup(65, 66, 67);
let triple q = tup(68, 69, 70);
y = id[int](x);
log y;
check (x == y);
2010-06-23 23:03:09 -05:00
b = id[char](a);
log b;
check (a == b);
2010-06-23 23:03:09 -05:00
q = id[triple](p);
x = p._2;
y = q._2;
log y;
check (x == y);
2010-06-23 23:03:09 -05:00
}