rust/src/test/compile-fail/by-move-pattern-binding.rs
2013-07-17 14:57:51 -07:00

23 lines
338 B
Rust

enum E {
Foo,
Bar(~str)
}
struct S {
x: E
}
fn f(x: ~str) {}
fn main() {
let s = S { x: Bar(~"hello") };
match &s.x {
&Foo => {}
&Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
};
match &s.x {
&Foo => {}
&Bar(ref identifier) => println(*identifier)
};
}