Skip to content

Instantly share code, notes, and snippets.

@jcaesar
Created January 18, 2021 11:16
Show Gist options
  • Save jcaesar/bfb1d1c9e9010c5d1865388f0985a1cb to your computer and use it in GitHub Desktop.
Save jcaesar/bfb1d1c9e9010c5d1865388f0985a1cb to your computer and use it in GitHub Desktop.
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