as_mut

Macro as_mut 

Source
macro_rules! as_mut {
    ($e:expr) => { ... };
}
Expand description

Obtain a new struct, each field is a mutable reference to the corresponding field of the input struct.

use structz::*;

let mut person = stru! {
    name: "John",
    age: 30,
    tags: vec!["smart", "handsome"],
};
let mut_person = as_mut!(person);
field!(mut_person.tags).pop();
assert_eq!(field!(&person.tags), &vec!["smart"]);