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