I know take can cleanly move a field, replacing it with it's Default implementation
and I know replace can cleanly move a field, with you providing a new value to backfill it with.
But what option exists to just drop the struct, taking the only field I care about from it? This would be handy in situations where Default can't be implemented, and building a garbage backfill value is a bit involved (with a giant builder, etc.)
If there's no Drop implementation, you can just move the field out.
let local = struct.field;
// Or if you really wanted the other fields to drop *right now*
let local = {
let struct = struct;
struct.field
};
If there is a Drop implementation, you can't do it without take or replace or similar, because Drop would then receive a &mut _ to a partially uninitialized (deinitialized) structure.