Crate abort_on_panic [] [src]

Current status

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

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.

Be careful when using this code, it's not being tested!
extern crate abort_on_panic;
pub fn test_macro() {
    let result = abort_on_panic!({ "value" });
    assert_eq!("value", result);
    abort_on_panic!("cannot panic inside FFI callbacks", {
        // ...



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



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.