Hacker News new | ask | show | jobs
by SCHiM 2540 days ago
I might be revealing myself as a novice rust programmer here, but can't you use 'ptr : * const()' as an opaque pointer type?

It's how I interface with C and C++ callback functions.

2 comments

You can, but there’s reasons a real external type feature is useful: https://github.com/rust-lang/rfcs/blob/master/text/1861-exte...
According to the nomicon[0], using a zero sized array in a repr(C) struct is the best practice for type safety. I also seem to remember someone saying the zero sized array is analogous to how LLVM bitcode represents void* in C.

[0] https://doc.rust-lang.org/nomicon/ffi.html#representing-opaq...