Skip to content

Instantly share code, notes, and snippets.

@Kimundi
Created January 12, 2014 12:49
Show Gist options
  • Save Kimundi/8384196 to your computer and use it in GitHub Desktop.
Save Kimundi/8384196 to your computer and use it in GitHub Desktop.
enum X {
A(~str),
B(~str)
}
struct Y {
x: X
}
fn f(a: &mut Y) {
let tmp = match a.x {
A(c) => c,
B(_) => fail!("Already B")
};
a.x = B(tmp);
}
fn main() {
let mut a = Y { x: A(~"42") };
f(&mut a);
}
ex.rs:12:9: 12:13 error: cannot move out of dereference of & pointer
ex.rs:12 A(c) => c,
^~~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /home/florian/devel/rust/src/libsyntax/diagnostic.rs:75
task '<main>' failed at 'explicit failure', /home/florian/devel/rust/src/librustc/lib.rs:453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment