aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/generic-fn.rs
blob: 4f93fef52c9cb169567678163c79950eeac5df05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// -*- rust -*-

fn id[T](&T x) -> T {
   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;
   assert (x == y);

   b = id[char](a);
   log b;
   assert (a == b);

   q = id[triple](p);
   x = p._2;
   y = q._2;
   log y;
   assert (x == y);

}