Crate abort_on_panic

Source
Expand description

§Current status

This crate is mostly obsolete. For almost all use cases, you should instead add the following to your Cargo.toml file:

[profile]
panic = 'abort'

§Original documentation

When calling Rust code from C, it’s unsafe to call panic!. Doing so may cause unsafe behavior. But when calling user-defined functions, we sometimes need to enforce these rules.

#[macro_use]
extern crate abort_on_panic;
 
#[test]
pub fn test_macro() {
    let result = abort_on_panic!({ "value" });
    assert_eq!("value", result);
 
    abort_on_panic!("cannot panic inside FFI callbacks", {
        // ...
    });
}

Macros§

abort_on_panic
Run a block of code, aborting the entire process if it tries to panic.

Structs§

PanicGuard
Once this object is created, it can only be destroyed in an orderly fashion. Attempting to clean it up from a panic handler will abort the process.