I can convert the closure to a &dyn Fn and look at the virtual table. Is there a way to do that without being too dependent on compiler implementation?
Also, how to get a pointer to the drop function to the closure? Can it be done without creating a Box<dyn Fn> first?
I know there could be data associated. The closure is represented as data + a function. The function will of course takes a pointer to the data as the first argument. I knew how to get a raw pointer to the data. I was wondering how to get a pointer to the function reliably.
Btw, note that the returned function pointer in the question above takes a *const T as the first argument.
you will notice that providing an actual instance f: &'_ F is not even needed; the "virtual method" can be extracted from the static type knowledge of F.
What you are looking for is getting a &'lt dyn Fn(f64) -> i32 in a FFI-compatible way: