Expand description
An implementation of the abort function that works without the standard library.
Provides an AbortGuard type to abort the process unless explicitly “defused”.
This can prevent panics from unwinding in the middle of unsafe code,
which trivially makes the code exception safe.
§Available implementations
The library offers multiple possible implementations, which can be controlled by using feature flags.
- Using the Rust standard library
std::process::abortfunction. This is enabled by using the “std” feature (disabled by default). - Using the C standard library
abortfunction from thelibccrate. This requires linking against the C standard library, but not the Rust one. This is enabled by using the “libc” feature (disabled by default). - If the
panic!implementation is known to abort instead of unwinding, then theabortfunction simply triggers a panic. This requires a recent version of Rust (1.60) in order to detect whether panics unwind or abort. - If no other implementations are available,
then the
abortfunction triggers a double-panic. This always triggers an abort regardless of the rust version or compiler settings.
Structs§
- Abort
Guard - A RAII guard that aborts the process unless it is explicitly defused.
Functions§
- abort
- Abort the process, as if calling
std::process::abortor the C standard libraryabortfunction. - immediate_
abort stdorlibcorabort-via-trap - Immediately call the platform-specific
abortimplementation, without invoking any other code. - trap
- Abnormally terminate the program by generating a trap instruction.