Last active
December 16, 2015 10:39
-
-
Save SiegeLord/5421229 to your computer and use it in GitHub Desktop.
Destructor order
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 Node | |
{ | |
Name : ~str, | |
Children : ~[Node] | |
} | |
impl Drop for Node | |
{ | |
fn finalize(&self) | |
{ | |
io::println(self.Name); | |
} | |
} | |
fn main() | |
{ | |
let mut parent = ~Node{Name : ~"parent", Children : ~[]}; | |
parent.Children.push(Node{Name : ~"child", Children : ~[]}); | |
} | |
/* | |
./bin | |
parent | |
child | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment