A workaround for Rust's lack of structural subtyping

from blog nickb.dev, | ↗ original
This example from a Rust issue does not compile: struct X { a: u8, b: u16, c: u32, d: i8 } struct Y { a: u8, b: u16, c: u32, d: i8 } let x = X { a: 1, b: 2, c: 3, d: 4 }; let y = Y { a: 5, ..x }; The code does not compile as the struct update syntax, which is the ..x part from above, is contingent on the target struct being a subtype of the...