pub trait DropWatch<T: ?Sized> {
// Required method
fn watch(this: &Self, drop_fn: impl FnOnce(&T) + 'static);
// Provided method
fn dropped(this: &Self) -> Dropped ⓘ { ... }
}
Required Methods§
Sourcefn watch(this: &Self, drop_fn: impl FnOnce(&T) + 'static)
fn watch(this: &Self, drop_fn: impl FnOnce(&T) + 'static)
Adds a function to be called just before this item is dropped. The function takes a reference to the item being dropped to avoid collision. /// # Example
use vigil::DropWatch;
let x = Vigil::new(5);
DropWatch::watch(&v, |it| print!("{} about to be dropped!", it));
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.