pub struct KillOnDrop<F: FnOnce()> { /* private fields */ }Expand description
Runs a cleanup closure exactly once when dropped, including during panic unwinding. Use it to guarantee spawned processes are killed, PTYs are closed, or temp state is removed even when an assertion fails mid-test.
FnOnce (not FnMut) is sufficient and most permissive: the guard fires
exactly one time, so the closure may move its captured state.
Call defuse to consume the guard without running
the cleanup (e.g. when the happy path already performed a graceful
teardown).
Implementations§
Trait Implementations§
Source§impl<F: FnOnce()> Debug for KillOnDrop<F>
impl<F: FnOnce()> Debug for KillOnDrop<F>
Source§impl<F: FnOnce()> Drop for KillOnDrop<F>
impl<F: FnOnce()> Drop for KillOnDrop<F>
Auto Trait Implementations§
impl<F> Forget for KillOnDrop<F>
impl<F> Freeze for KillOnDrop<F>
impl<F> RefUnwindSafe for KillOnDrop<F>where
Option<F>: RefUnwindSafe,
impl<F> Send for KillOnDrop<F>
impl<F> Sync for KillOnDrop<F>
impl<F> Unpin for KillOnDrop<F>
impl<F> UnsafeUnpin for KillOnDrop<F>where
Option<F>: UnsafeUnpin,
impl<F> UnwindSafe for KillOnDrop<F>where
Option<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