Created
October 28, 2014 07:21
-
-
Save phildawes/a6f99b1fb5c3966ecb14 to your computer and use it in GitHub Desktop.
mutating a field after move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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