pub struct ScopeGuard<T, F, S = Always>{ /* private fields */ }Expand description
Owns a value and conditionally passes it to an action when dropped.
The guarded value is accessible through Deref and DerefMut. The
action receives ownership of the final value and runs at most once.
Panics from the strategy or a drop-time action propagate. A second panic
during unwinding may abort the process.
Implementations§
Source§impl<T, F, S> ScopeGuard<T, F, S>
impl<T, F, S> ScopeGuard<T, F, S>
Sourcepub const fn with_strategy(value: T, action: F) -> Self
pub const fn with_strategy(value: T, action: F) -> Self
Creates an armed guard using strategy S.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Disarms the guard and returns its value without running the action.
Sourcepub fn into_parts(self) -> (T, F)
pub fn into_parts(self) -> (T, F)
Disarms the guard and returns both its value and action.
Trait Implementations§
Source§impl<T, F, S> Debug for ScopeGuard<T, F, S>
impl<T, F, S> Debug for ScopeGuard<T, F, S>
Source§impl<T, F, S> Deref for ScopeGuard<T, F, S>
impl<T, F, S> Deref for ScopeGuard<T, F, S>
Source§impl<T, F, S> DerefMut for ScopeGuard<T, F, S>
impl<T, F, S> DerefMut for ScopeGuard<T, F, S>
Source§impl<T, F, S> Drop for ScopeGuard<T, F, S>
impl<T, F, S> Drop for ScopeGuard<T, F, S>
Auto Trait Implementations§
impl<T, F, S> Freeze for ScopeGuard<T, F, S>
impl<T, F, S> RefUnwindSafe for ScopeGuard<T, F, S>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<T, F, S> Send for ScopeGuard<T, F, S>
impl<T, F, S> Sync for ScopeGuard<T, F, S>
impl<T, F, S> Unpin for ScopeGuard<T, F, S>
impl<T, F, S> UnsafeUnpin for ScopeGuard<T, F, S>where
T: UnsafeUnpin,
F: UnsafeUnpin,
impl<T, F, S> UnwindSafe for ScopeGuard<T, F, S>where
T: UnwindSafe,
F: UnwindSafe,
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