2012-12-15 02:50:48 +01:00
|
|
|
enum E {
|
|
|
|
Foo,
|
2014-05-23 01:57:53 +02:00
|
|
|
Bar(String)
|
2012-12-15 02:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
x: E
|
|
|
|
}
|
|
|
|
|
2014-05-23 01:57:53 +02:00
|
|
|
fn f(x: String) {}
|
2012-12-15 02:50:48 +01:00
|
|
|
|
|
|
|
fn main() {
|
2014-11-06 09:05:53 +01:00
|
|
|
let s = S { x: E::Bar("hello".to_string()) };
|
2019-04-22 09:40:08 +02:00
|
|
|
match &s.x { //~ ERROR cannot move
|
2014-11-06 09:05:53 +01:00
|
|
|
&E::Foo => {}
|
2019-04-22 09:40:08 +02:00
|
|
|
&E::Bar(identifier) => f(identifier.clone())
|
2012-12-15 02:50:48 +01:00
|
|
|
};
|
|
|
|
match &s.x {
|
2014-11-06 09:05:53 +01:00
|
|
|
&E::Foo => {}
|
|
|
|
&E::Bar(ref identifier) => println!("{}", *identifier)
|
2012-12-15 02:50:48 +01:00
|
|
|
};
|
|
|
|
}
|