Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
Last active December 16, 2015 10:39
Show Gist options
  • Save SiegeLord/5421229 to your computer and use it in GitHub Desktop.
Save SiegeLord/5421229 to your computer and use it in GitHub Desktop.
Destructor order
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