Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know about this technique but it uses too much unsafe for my taste. Not that it's bad or anything, just a personal preference.




It can be done in 100% safe code as far as Rust is concerned (if you use `dyn Fn` type instead of c_void).

The only unsafe here is to demonstrate it works with C/C++ FFI (where void* userdata is actually not type safe)


Yes but my problem wasn’t with the user data pointer but the fact that I needed a STATIC generic lambda. Static because the C library then forks and continues to call the lambda in the new process but I also type based conversions in it.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: