Struct scope_guard::Scope
source · pub struct Scope<T, F: FnOnce(T)> { /* private fields */ }
Expand description
RAII Scope, running closure in destructor.
Implementations§
source§impl<T, F: FnOnce(T)> Scope<T, F>
impl<T, F: FnOnce(T)> Scope<T, F>
sourcepub fn stack<NF: FnOnce(&mut T)>(self, dtor: NF) -> Scope<T, impl FnOnce(T)>
pub fn stack<NF: FnOnce(&mut T)>(self, dtor: NF) -> Scope<T, impl FnOnce(T)>
Adds new function to be invoked in scope of the guard.
This function is executed before current one. Similarly to how stack variables dtors are invoked in reverse order.
Note that stacked function cannot take guarded by value, only original function will retain owned value.