Created
August 3, 2015 16:09
-
-
Save anonymous/7918bf9f83d079ac8960 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or 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 Yell { name: &'static str } | |
impl Drop for Yell { | |
fn drop(&mut self) { | |
println!("{} dropped!", self.name); | |
} | |
} | |
fn main() { | |
let bob = Yell { name: "Bob" }; | |
let carol = Yell { | |
name: { | |
let carols_dad = Yell { name: "David" }; | |
"Carol" | |
} //carols_dad out-of-scopes here | |
}; | |
let ed = Yell { name: "Ed" }; | |
let frank = Yell { name: panic!("Panic will destruct all objects reversly-ordered") }; | |
println!("We never get to Gregor"); | |
//never executes | |
let gregor = Yell { name: "Gregor" }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment