Trait vigil::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.

Object Safety§

This trait is not object safe.

Implementors§

source§

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