pub struct Scope<'env> { /* private fields */ }
Expand description
A Scope
is used to register callbacks.
See Scope::register.
Implementations§
Source§impl<'env> Scope<'env>
impl<'env> Scope<'env>
Sourcepub 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>
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>
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!
.
Trait Implementations§
Auto Trait Implementations§
impl<'env> !Freeze for Scope<'env>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more