Created
April 15, 2015 20:49
-
-
Save XMPPwocky/6a43d281a0bc4ca1c138 to your computer and use it in GitHub Desktop.
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
Destroy: | |
````rust | |
trait Destroy { | |
/// Called only when panicking | |
pub fn destroy(&mut self); | |
} | |
```` | |
Drop: | |
````rust | |
trait Drop { | |
/// Called when going out of scope. May safely be left uncalled, although this can leak memory or resources so it's not recommended. | |
/// Never called when panicking. (Notably, this could it O.K. to panic in Drop, which is nice.) | |
/// (Should panicking in Drop call Destroy?) | |
pub fn drop(&mut self); | |
} | |
```` | |
Destroy works sorta like Drop does today; if you don't implement it explicitly, nothing happens when you're panicking. | |
Not implementing Drop now makes your type linear. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment