I have some code generated by bindgen that has function pointers represented by Option<T>.
pub type SomeFnPointerType = ::std::option::Option<
unsafe extern "C" fn ( /* .. large number of argument types .. */)
-> /* return type */
> ;
I want to store the unwrapped values in a structure. However, there are no type aliases for the inner function pointer types, so how can I define that structure? I cannot refactor the code because it's automatically generated.
I want to do something like this (in C++'ish pseudo code):
struct FunctionTable {
decltype((None as SomeFnPointerType).unwrap()) unwrappedFn;
/* ... */
};
or maybe just SomeFnPointerType::T if that is allowed.
Is it possible to achieve that in Rust? If not, the only way I see it is to manually define those types by copy-pasting code from the generated file into a separate handwritten file and keep the types in sync manually.