I've been ready most examples I can find on this topic but it's still unclear to me how I can massage a rust closure (or any function really) into this type
Here is the type generate by bindgen
pub type GxB_binary_function = ::std::option::Option<
unsafe extern "C" fn(
arg1: *mut ::std::os::raw::c_void,
arg2: *const ::std::os::raw::c_void,
arg3: *const ::std::os::raw::c_void,
),
>;
this is how the C header looks like
typedef void (*GxB_binary_function) (void *, const void *, const void *) ;
#undef GrB_BinaryOp_new
GB_PUBLIC
GrB_Info GrB_BinaryOp_new
(
GrB_BinaryOp *binaryop, // handle for the new binary operator
GxB_binary_function function, // pointer to the binary function
GrB_Type ztype, // type of output z
GrB_Type xtype, // type of input x
GrB_Type ytype // type of input y
) ;
the Rust closure I would like to massage into this is
fn new<F>(f: &mut F) -> GrB_BinaryOp
where
F: FnMut(&mut Z, X, Y) -> (),
I do not hold a mutable reference to C it is owned by the C lib I'm trying to call
I tried using ffi_helpers::split_colsure
but i'm getting the wrong type
incorrect number of function parameters
expected fn pointerunsafe extern \"C\" fn(*mut std::ffi::c_void, *const std::ffi::c_void, *const std::ffi::c_void)
found fn pointerunsafe extern \"C\" fn(*mut std::ffi::c_void, &mut Z, X, Y)
"