alef 0.79.1

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![allow(
    clippy::too_many_arguments,
    clippy::not_unsafe_ptr_arg_deref,
    unused_variables,
    unused_mut
)]

use std::ffi::{c_char, c_void, CStr, CString};
use std::sync::Arc;
use std::panic;
use super::{AlefHandle, HandleError, insert_handle, remove_handle, set_handle_error, take_handle, with_handle, with_handle_mut};

fn catch_ffi_panic<T>(fallback: T, body: impl FnOnce() -> T) -> T {
    match panic::catch_unwind(panic::AssertUnwindSafe(body)) {
        Ok(value) => value,
        Err(_) => fallback,
    }
}