The workaround I currently use for opaque types is also really awful:
mod foo { #[repr(C)] pub struct Foo([u8;0]); }
Which, like your solution using u8
instead of [u8;0]
also runs into the moving problems, but has the advantage of being zero sized which means that things like mem::swap
-ing between pointers of that type is a no-op.
My suggested solution at one point to this problem was [Pre-RFC] Opaque Structs - but the thread didn’t seem to go anywhere.