Let's suppose we have two structs with identical fields (and types).
struct A {
pub data1: i32;
pub data2: string;
}
struct B {
pub data1: i32;
pub data2: string;
}
To copy the struct A and B, I have to do
fn convert_A_to_B(a: A) -> B {
B {
data1: a.data1,
data2: a.data2
}
}
I wish I can do something like
B {
..a
}
but it's not possible since types are different. Is there any macro or syntax that do the simple move of all identical fields?