Skip to main content

save_fields

Macro save_fields 

Source
macro_rules! save_fields {
    ($me:ident, $context:ident, [$($field:ident),+ $(,)?]) => { ... };
    ($context:ident, [$($field:ident),+ $(,)?]) => { ... };
}
Expand description

Build a Record from a list of fields.

Two forms are supported:

  • save_fields!(self, context, [a, b, c]) reads each field as self.a, self.b, etc. Use this from Save::save for plain structs.
  • save_fields!(context, [a, b, c]) reads each field from a local binding of the same name. Use this inside enum match arms where the variant’s payload has already been destructured into local bindings. Those bindings are assumed to be references (which is automatic when matching against &self); for an owned local, take a reference explicitly first.