Skip to content

Support FieldRefMut::replace #135

Description

@RaitoBezarius

Extension of #134 for non-enum structures. In non-enum structures, there's no way to move a single non-Copy field out and leave a placeholder (or a default constructed type). The usual Rust pattern is std::mem::replace(&mut foo.field, placeholder) and I don't think zngur supports A C++ equivalent atm.

My proposal would be to generate a Rust extern function per field that does the std::mem::replace and on the C++ side you can call T replace(T placeholder) to FieldRefMut (incl. specializations).
This is always safe because the field is always left initialized.

#133 as a pre-requisite would make sense to put replace in the CRTP perhaps if this idea is retained.

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