macro_rules! update {
{$($t:tt)*} => { ... };
{$e:expr, $($t:tt)*} => { ... };
}
Expand description
Update a struct value.
Can be called with a ..<expr>
at the end (like normal struct update syntax) or a <expr>,
at the beginning.
use deep_struct_update::update;
#[derive(Default)]
struct A {
b: B
}
#[derive(Default)]
struct B {
c: C
}
#[derive(Default)]
struct C {
num: i32
}
let a = update! {
b: { c: { num: 42 }}
..A::default()
};
assert_eq!(a.b.c.num, 42);