rust/src/test/run-pass/record-pat.rs

16 lines
327 B
Rust
Raw Normal View History

enum t1 { a(int); b(uint); }
2011-07-27 07:19:39 -05:00
type t2 = {x: t1, y: int};
enum t3 { c(t2, uint); }
2011-07-11 07:13:20 -05:00
fn m(in: t3) -> int {
2011-07-11 07:13:20 -05:00
alt in {
2011-07-27 07:19:39 -05:00
c({x: a(m), _}, _) { ret m; }
c({x: b(m), y: y}, z) { ret (m + z as int) + y; }
2011-07-11 07:13:20 -05:00
}
}
fn main() {
2011-07-27 07:19:39 -05:00
assert (m(c({x: a(10), y: 5}, 4u)) == 10);
assert (m(c({x: b(10u), y: 5}, 4u)) == 19);
}