Crate abort_on_panic [] [src]

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.

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.