Rust closure as callback for C bindings receiving garbage value in captured variable
问题 I'm writing Rust wrappers for C bindings so that they look more Rusty. One such C function is this: void mosquitto_connect_callback_set( struct mosquitto * mosq, void (*on_connect)(struct mosquitto *, void *, int) ) I'm using the below technique to pass a Rust closure as the user data to above binding ( void* in the callback) so that the Rust closure will be called when the C callback is invoked. // Registered callback is called when the broker sends a CONNACK message in response // to a