object_mut_access

Macro object_mut_access 

Source
macro_rules! object_mut_access {
    ($vis:vis $name:ident { $($field:ident : $type:ty),* }) => { ... };
}
Expand description

This macro creates an ARMC wrapper in a struct defined in the macro’s scope, along with a new constructor and getter methods for each field, and mutable setter methods for each field with the suffix _mut.

§Example


object_mut_access!(MyStruct {
    foo: u32,
    bar: String,
});

let mut my_struct = MyStruct::new(42, "hello".to_string());

assert_eq!(*my_struct.foo(), 42);

my_struct.foo_mut(13);
assert_eq!(*my_struct.foo(), 13);