vigil

Trait DropWatch

Source
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§

Source

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§

Source

fn dropped(this: &Self) -> Dropped

Makes a Dropped struct, which is a Future that completes just before the item is dropped.

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.

Implementors§

Source§

impl<T: ?Sized> DropWatch<T> for Vigil<T>