[][src]Macro abi_stable::extern_fn_panic_handling

macro_rules! extern_fn_panic_handling {
    ( $($fn_contents:tt)* ) => { ... };
}

Use this to make sure that you handle panics inside extern fn correctly.

This macro causes an abort if a panic reaches this point.

It does not prevent functions inside from using ::std::panic::catch_unwind to catch the panic.

Example

use std::fmt;

use abi_stable::{
    extern_fn_panic_handling,
    std_types::RString,
};


pub extern "C" fn print_debug<T>(this: &T,buf: &mut RString)
where
    T: fmt::Debug,
{
    extern_fn_panic_handling! {
        use std::fmt::Write;

        println!("{:?}",this);
    }
}