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