]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // run-pass |
2 | #![allow(non_shorthand_field_patterns)] | |
c34b1796 | 3 | |
223e47cc LB |
4 | enum Foo { |
5 | Bar { | |
c34b1796 AL |
6 | x: isize, |
7 | y: isize | |
223e47cc LB |
8 | }, |
9 | Baz { | |
1a4d82fc JJ |
10 | x: f64, |
11 | y: f64 | |
223e47cc LB |
12 | } |
13 | } | |
14 | ||
15 | fn f(x: &Foo) { | |
16 | match *x { | |
1a4d82fc | 17 | Foo::Baz { x: x, y: y } => { |
970d7e83 LB |
18 | assert_eq!(x, 1.0); |
19 | assert_eq!(y, 2.0); | |
223e47cc | 20 | } |
1a4d82fc | 21 | Foo::Bar { y: y, x: x } => { |
970d7e83 LB |
22 | assert_eq!(x, 1); |
23 | assert_eq!(y, 2); | |
223e47cc LB |
24 | } |
25 | } | |
26 | } | |
27 | ||
28 | pub fn main() { | |
1a4d82fc | 29 | let x = Foo::Bar { x: 1, y: 2 }; |
223e47cc | 30 | f(&x); |
1a4d82fc | 31 | let y = Foo::Baz { x: 1.0, y: 2.0 }; |
223e47cc LB |
32 | f(&y); |
33 | } |