Yes, that's true. However, in this case the reason I wanted to use
external_types is a bit more complex. I am trying to oxidize a C library, which exports many functions returning pointers to opaque types. In Rust we have some limitations because visibility is way better than C, but for these cases it can be troublesome.
The following example does not compile: playground.
The reason is that I cannot export a
*const A if
I can use extern types feature to workaround the situation: defining an opaque extern type
mod to choose between the real structure and the opaque type and cast between the pointers. Playground
You can imagine that, in this C-like codebase, I will need to use
null_mut quite often. I can obviously copy-paste the
std code in a module, add
: ?Sized to the trait bound and go on, but it is not a solution I would like to adopt.
std is wrong, maybe it should be fixed. If it is right, I should not create a null pointer in that way.