rust/src/test/compile-fail/by-move-pattern-binding.rs

23 lines
338 B
Rust
Raw Normal View History

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 => {}
2013-07-02 12:47:32 -07:00
&Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
};
match &s.x {
&Foo => {}
&Bar(ref identifier) => println(*identifier)
};
}