Last active
March 28, 2019 05:12
-
-
Save siburu/6e4db443fdcad98a296c6758455f7942 to your computer and use it in GitHub Desktop.
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 Hoge { | |
agony: String | |
} | |
impl Drop for Hoge { | |
fn drop(&mut self) { | |
println!("drop: {}", self.agony); | |
} | |
} | |
fn main() { | |
let mut h = Hoge { agony: String::from("bye bye") }; | |
// shadow1: Hoge => &mut Hoge::agony | |
let h = &mut h.agony; | |
println!("after shadow1: {}", h); | |
*h = String::from("hello hello"); | |
// shadow 2: &mut Hoge::agony => integer | |
let h = 123; | |
println!("after shadow2: {}", h); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment