as_ref

Macro as_ref 

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

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

use structz::*;

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