Created
January 18, 2021 11:16
-
-
Save jcaesar/bfb1d1c9e9010c5d1865388f0985a1cb 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
struct BtOnDrop<T> { | |
inner: T | |
} | |
impl<T> BtOnDrop<T> { | |
fn new(inner: T) -> Self { BtOnDrop { inner } } | |
} | |
impl<T> std::ops::Deref for BtOnDrop<T> { | |
type Target = T; | |
fn deref(&self) -> &<Self as std::ops::Deref>::Target { &self.inner } | |
} | |
impl<T> Drop for BtOnDrop<T> { | |
fn drop(&mut self) { | |
println!("Dropping {}, {:?}", std::any::type_name::<T>(), backtrace::Backtrace::new()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment