Created
January 24, 2020 14:39
-
-
Save rust-play/078a4f05ff06569282bb82bd1c68a5d6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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 PrintInDrop(&'static str); | |
impl Drop for PrintInDrop { | |
fn drop(&mut self) { | |
println!("{}", self.0); | |
} | |
} | |
fn bar(_: &PrintInDrop) -> PrintInDrop { | |
PrintInDrop("ret") | |
} | |
fn okok() -> PrintInDrop { | |
let _foo = PrintInDrop("foo"); | |
bar(&PrintInDrop("temp")) | |
} | |
fn main() { | |
okok(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment