After matching an enum variant (thanks to #125), there's no way to move individual fields out. The variant class owns the parent enum data and its destructor will always drop it.
A workaround is wrapping the entire variant in a smart pointer and return it.
An alternative is to add a mechanism on the Rust side to ptr::read the parent, destructure the variant, ptr::write each field to separate output pointers. On the C++ side, add a destructure() function to variant classes that calls the Rust function, assume_deinits the __zngur_parent thing so that the variant destructor becomes a no-op.
I'm not exactly sure if this proposal is legal but if this would make sense, I can try contributing it.
After matching an enum variant (thanks to #125), there's no way to move individual fields out. The variant class owns the parent enum data and its destructor will always drop it.
A workaround is wrapping the entire variant in a smart pointer and return it.
An alternative is to add a mechanism on the Rust side to
ptr::readthe parent, destructure the variant,ptr::writeeach field to separate output pointers. On the C++ side, add adestructure()function to variant classes that calls the Rust function,assume_deinits the__zngur_parentthing so that the variant destructor becomes a no-op.I'm not exactly sure if this proposal is legal but if this would make sense, I can try contributing it.