2012-01-19 18:31:08 -08:00
|
|
|
enum t1 { a(int), b(uint), }
|
2011-07-27 14:19:39 +02:00
|
|
|
type t2 = {x: t1, y: int};
|
2012-01-19 18:31:08 -08:00
|
|
|
enum t3 { c(t2, uint), }
|
2011-07-11 14:13:20 +02:00
|
|
|
|
2011-09-12 11:27:30 +02:00
|
|
|
fn m(in: t3) -> int {
|
2011-07-11 14:13:20 +02:00
|
|
|
alt in {
|
2011-07-27 14:19:39 +02:00
|
|
|
c({x: a(m), _}, _) { ret m; }
|
2012-02-09 11:50:54 +01:00
|
|
|
c({x: b(m), y: y}, z) { ret ((m + z) as int) + y; }
|
2011-07-11 14:13:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 14:19:39 +02:00
|
|
|
assert (m(c({x: a(10), y: 5}, 4u)) == 10);
|
|
|
|
assert (m(c({x: b(10u), y: 5}, 4u)) == 19);
|
2011-08-19 15:16:48 -07:00
|
|
|
}
|