macro_rules! define_field_accessors {
($field_name:ident, $add_method:ident, $get_method:ident) => { ... };
}Expand description
Macro to generate add/get accessor methods for a field collection.
This macro is designed to be used inside impl blocks and generates two methods:
add_<add_method_name>()- adds a field to the collection (mutable)<get_method_name>()- gets the collection (immutable)
Both methods are marked with #[must_use] for the getter where appropriate.
§Example
ⓘ
pub struct MyRecord {
my_fields: Vec<Field>,
}
impl MyRecord {
// Use the macro to generate add_my_field() and my_fields() methods
define_field_accessors!(my_fields, add_my_field, my_fields);
}