extern "C" {
fn some_cfunc(callback: unsafe extern "C" fn());
}
fn some_func(callback: fn()) {
extern "C" fn cb() {
callback();
}
unsafe { some_cfunc(cb) };
}
I want to create a rust wrapper of the some_cfunc function in a C library and accept a rust callback. However the example is not working:
can't capture dynamic environment in a fn item
use the `|| { ... }` closure form instead (rustc E0434)
And wrap it with closure seem doesn't help....
How should I achieve that? Do I have to store the rust callback someway?