pub struct AbortOnDrop(pub &'static str);
Expand description
Zero-sized struct that calls std::process::abort()
if dropped
This is useful to make code exception safe. If there is a region that must not panic for safety reasons, you can use this to prevent further unwinding, at least.
Before aborting, the provided string is printed. If the guarded code in the
example panics, FATAL: Foo panicked. Aborting.
will be printed to stderr.
§Example
let panic_guard = AbortOnDrop("Foo panicked.");
// ... code that might panic ...
panic_guard.defuse();
Tuple Fields§
§0: &'static str
Implementations§
Source§impl AbortOnDrop
impl AbortOnDrop
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AbortOnDrop
impl RefUnwindSafe for AbortOnDrop
impl Send for AbortOnDrop
impl Sync for AbortOnDrop
impl Unpin for AbortOnDrop
impl UnwindSafe for AbortOnDrop
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