pub struct ClosureGuard<F: FnOnce()> { /* private fields */ }Expand description
Guard that executes a closure when dropped.
Useful for ensuring cleanup logic runs even on early returns or panics.
§Examples
use xet_runtime::utils::ClosureGuard;
let _guard = ClosureGuard::new(|| {
println!("cleanup!");
});
// closure runs when _guard is droppedImplementations§
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for ClosureGuard<F>where
F: Freeze,
impl<F> RefUnwindSafe for ClosureGuard<F>where
F: RefUnwindSafe,
impl<F> Send for ClosureGuard<F>where
F: Send,
impl<F> Sync for ClosureGuard<F>where
F: Sync,
impl<F> Unpin for ClosureGuard<F>where
F: Unpin,
impl<F> UnsafeUnpin for ClosureGuard<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for ClosureGuard<F>where
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