pub struct AbortOnDrop<'a>(pub &'a 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: &'a strImplementations§
Source§impl AbortOnDrop<'_>
impl AbortOnDrop<'_>
Trait Implementations§
Source§impl<'a> Debug for AbortOnDrop<'a>
impl<'a> Debug for AbortOnDrop<'a>
Source§impl Drop for AbortOnDrop<'_>
impl Drop for AbortOnDrop<'_>
Auto Trait Implementations§
impl<'a> Freeze for AbortOnDrop<'a>
impl<'a> RefUnwindSafe for AbortOnDrop<'a>
impl<'a> Send for AbortOnDrop<'a>
impl<'a> Sync for AbortOnDrop<'a>
impl<'a> Unpin for AbortOnDrop<'a>
impl<'a> UnsafeUnpin for AbortOnDrop<'a>
impl<'a> UnwindSafe for AbortOnDrop<'a>
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