Struct btlib::drop_trigger::DropTrigger
source · pub struct DropTrigger<F: FnOnce()> { /* private fields */ }
Expand description
Calls a closure when it’s dropped, unless it’s disarmed first. This struct is useful for implementing cleanup operations.
Implementations§
source§impl<F: FnOnce()> DropTrigger<F>
impl<F: FnOnce()> DropTrigger<F>
sourcepub fn new(trigger: F) -> Self
pub fn new(trigger: F) -> Self
Creates a DropTrigger which will call the given closure when dropped.
sourcepub fn disarm(&mut self) -> bool
pub fn disarm(&mut self) -> bool
Disarms this DropTrigger so that its closure will not be called when when it’s dropped.
Trait Implementations§
Auto Trait Implementations§
impl<F> RefUnwindSafe for DropTrigger<F>where F: RefUnwindSafe,
impl<F> Send for DropTrigger<F>where F: Send,
impl<F> Sync for DropTrigger<F>where F: Sync,
impl<F> Unpin for DropTrigger<F>where F: Unpin,
impl<F> UnwindSafe for DropTrigger<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