2012-12-14 19:50:48 -06:00
|
|
|
enum E {
|
|
|
|
Foo,
|
2014-05-22 18:57:53 -05:00
|
|
|
Bar(String)
|
2012-12-14 19:50:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
x: E
|
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn f(x: String) {}
|
2012-12-14 19:50:48 -06:00
|
|
|
|
|
|
|
fn main() {
|
2014-11-06 02:05:53 -06:00
|
|
|
let s = S { x: E::Bar("hello".to_string()) };
|
2019-04-22 02:40:08 -05:00
|
|
|
match &s.x { //~ ERROR cannot move
|
2014-11-06 02:05:53 -06:00
|
|
|
&E::Foo => {}
|
2019-04-22 02:40:08 -05:00
|
|
|
&E::Bar(identifier) => f(identifier.clone())
|
2012-12-14 19:50:48 -06:00
|
|
|
};
|
|
|
|
match &s.x {
|
2014-11-06 02:05:53 -06:00
|
|
|
&E::Foo => {}
|
|
|
|
&E::Bar(ref identifier) => println!("{}", *identifier)
|
2012-12-14 19:50:48 -06:00
|
|
|
};
|
2022-12-08 11:02:54 -06: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 19:50:48 -06:00
|
|
|
}
|