blob: ade1a697037c5a4cb8845b624f5ecb659b3569f4 (
plain)
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
33
|
// run-pass
#![allow(non_shorthand_field_patterns)]
enum Foo {
Bar {
x: isize,
y: isize
},
Baz {
x: f64,
y: f64
}
}
fn f(x: &Foo) {
match *x {
Foo::Baz { x: x, y: y } => {
assert_eq!(x, 1.0);
assert_eq!(y, 2.0);
}
Foo::Bar { y: y, x: x } => {
assert_eq!(x, 1);
assert_eq!(y, 2);
}
}
}
pub fn main() {
let x = Foo::Bar { x: 1, y: 2 };
f(&x);
let y = Foo::Baz { x: 1.0, y: 2.0 };
f(&y);
}
|