Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 24, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/078a4f05ff06569282bb82bd1c68a5d6 to your computer and use it in GitHub Desktop.
Save rust-play/078a4f05ff06569282bb82bd1c68a5d6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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