rust/src/test/compile-fail/by-move-pattern-binding.rs
2013-05-03 20:01:42 -04:00

23 lines
366 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(copy identifier) //~ ERROR by-move pattern bindings may not occur
};
match &s.x {
&Foo => {}
&Bar(ref identifier) => io::println(*identifier)
};
}