Closed Earthmark closed 8 months ago
This allows wrappers to be easily (and generically) be implemented for callbacks.
callback!(MyCallback(value: u32) -> u32); fn wrap_callback<Arg, Ret, Callback>(wrapper: Callback, arg: Arg) -> Ret where Callback: Into<Option<extern "C" fn(Arg) -> Ret>>, Ret: Default, { // log that it was called or something. if let Some(callback) = wrapper.into() { callback(arg) } else { Default::default() } } #[ffi_function] #[no_mangle] pub extern "C" fn pattern_callback_1(callback: MyCallback, x: u32) -> u32 { wrap_callback(callback, x) }
Thanks!
This allows wrappers to be easily (and generically) be implemented for callbacks.