How do I use the Rust memory allocator for a C library that can be provided an allocator?
问题 I'm writing Rust bindings to a C library which has the option to use a third-party memory allocator. Its interface looks like this: struct allocator { void*(*alloc)(void *old, uint); void(*free)(void*); }; The corresponding Rust struct is, I guess, the following: #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct Allocator { alloc: Option<extern "C" fn(*mut c_void, c_uint) -> *mut c_void>, free: Option<extern "C" fn(*mut c_void)>, } How can I implement these two extern functions