[][src]Struct scoped_callback::Scope

pub struct Scope<'env> { /* fields omitted */ }

A Scope is used to register callbacks. See Scope::register.

Methods

impl<'env> Scope<'env>[src]

pub fn register<'scope, A: 'static, R: 'static, H: 'static>(
    &'scope self,
    c: impl FnMut(A) -> R + 'env,
    register: impl FnOnce(Box<dyn FnMut(A) -> R>) -> H + 'env,
    deregister: impl FnOnce(H) + 'env
) -> Registered<'env, 'scope>
[src]

Register the function c with local lifetime 'env using the register and deregister functions that handle only 'static lifetime functions. The returned Registered object will, when dropped, invoke the deregister function.

If the Registered object is std::mem::forget-ed, Scope::drop will perform the de-registration.

Note: If the callback passed to the register function is invoked after deregister has been invoked, the callback will panic!.

pub fn future<'scope>(
    &'scope self,
    future: LocalBoxFuture<'env, ()>
) -> impl Future<Output = ()> + 'static
[src]

Wrap a scoped Future into one with a 'static lifetime. Future::poll will panic! if called after the scope has been dropped.

Trait Implementations

impl<'env> Drop for Scope<'env>[src]

Auto Trait Implementations

impl<'env> !RefUnwindSafe for Scope<'env>

impl<'env> !Send for Scope<'env>

impl<'env> !Sync for Scope<'env>

impl<'env> Unpin for Scope<'env>

impl<'env> !UnwindSafe for Scope<'env>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.