struct A
{
field1 : i32,
field2 : i32
}
impl Default for A
{
fn default() -> Self
{
Self
{
field1 : 0,
field2 : 1
}
}
}
struct B
{
field2 : i32
}
fn main()
{
let b = B{ field2 : 2 };
let a = A
{
field2 : b.field2,
.. Default::default()
};
}
Is there an expression that allows to pass fields of b
into initialization of struct A
without explicitly typing field names in case when both structs have common properties of the same type?
Like use:
let a = A
{
..b,
.. Default::default()
};
Instead of:
let a = A
{
field2 : b.field2,
.. Default::default()
};