Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mutating a field after move
struct Foo {
name: String
}
impl Drop for Foo {
fn drop(&mut self) {
println!("dropped");
}
}
fn another_fn(f: Foo) {
println!("f name is {}",f.name);
}
fn main() {
let mut f = Foo {name: "myname".to_string()};
another_fn(f); // f 'moved' to another_fn
f.name = "another name".to_string(); // why am I allowed to do this?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.