unwind_aborts

Crates.iounwind_aborts
lib.rsunwind_aborts
version0.1.1
sourcesrc
created_at2020-03-28 00:55:25.849622
updated_at2020-03-28 00:57:46.941838
descriptionPrevent your panics from unwinding past FFI boundaries with this one simple trick!
homepage
repositoryhttps://github.com/agausmann/unwind_aborts
max_upload_size
id223691
size5,840
Adam Gausmann (agausmann)

documentation

README

unwind_aborts

Prevent your panics from unwinding past FFI boundaries with this one simple trick!

Intended to be used in place of #[unwind(aborts)] until it is stabilized.

Usage

Add this to your [dependencies] in Cargo.toml:

unwind_aborts = "0.1.0"

Annotate your functions with #[unwind_aborts] to catch stack unwinding and abort the process instead:

use unwind_aborts::unwind_aborts;

#[unwind_aborts]
pub extern fn foo() {
    panic!("this is safe");
}

The example above is equivalent to:

pub extern fn foo() {
    let result = std::panic::catch_unwind(|| {
        panic!("this is safe");
    });
    match result {
        Ok(x) => x,
        Err(_) => std::process::abort(),
    }
}
Commit count: 4

cargo fmt