Skip to content

Variant field destructure #134

Description

@RaitoBezarius

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions