macro_rules! rebind_closure {
($external_name:ty, $closure:expr) => { ... };
}Expand description
Rebinds a Closure from this crate to a Closure type defined externally.
If you use bindgen to make bindings to C/C++ functions accepting this Closure type then the bindings won’t
be defined in terms of c_closures, instead your functions will want an instance of your own Closure definition.
This macro provides a convenient way to rebind them.
use c_closures::{Closure, rebind_closure};
mod ffi {
// Import of bindgen generated closure here.
// i.e. include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
// elsewhere
let c = rebind_closure!(ffi::Closure, Closure::fn_not_mut(|_: ()| 2 + 2));