Skip to main content

OnDropFutureExt

Trait OnDropFutureExt 

Source
pub trait OnDropFutureExt: Future + Sized {
    // Provided method
    fn on_drop<F: FnOnce()>(self, on_drop: F) -> OnDropFuture<Self, F> ⓘ { ... }
}
Expand description

Extension trait for running a callback when a pending future is dropped.

Provided Methods§

Source

fn on_drop<F: FnOnce()>(self, on_drop: F) -> OnDropFuture<Self, F> ⓘ

Wraps this future so that on_drop is called if the future is dropped before it completes. The callback is cancelled once the future completes, whatever its output.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§