RSSAmplifier

nickb.dev · Nov 18, 2021

A workaround for Rust's lack of structural subtyping

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

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 base (i.e. the…

Read on nickb.dev

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.