Apoplexy@lemmy.world to Rust@programming.devEnglish · 7 months agoTracking issue for RFC 3681: Default field values · Issue #132162 · rust-lang/rustgithub.comexternal-linkmessage-square3fedilinkarrow-up127arrow-down11
arrow-up126arrow-down1external-linkTracking issue for RFC 3681: Default field values · Issue #132162 · rust-lang/rustgithub.comApoplexy@lemmy.world to Rust@programming.devEnglish · 7 months agomessage-square3fedilink
minus-squared_k_bo@feddit.orglinkfedilinkarrow-up3·edit-27 months agoThis is really great and would solve the problem that led me to create constructor-lite. With this RFC, its usage could be replaced with #[derive(Debug, PartialEq)] struct Movie { title: String, year: Option<u16> = None, } assert_eq!( Movie { title: "Star Wars".to_owned(), .. }, Movie { title: "Star Wars".to_owned(), year: None }, )
This is really great and would solve the problem that led me to create constructor-lite.
With this RFC, its usage could be replaced with
#[derive(Debug, PartialEq)] struct Movie { title: String, year: Option<u16> = None, } assert_eq!( Movie { title: "Star Wars".to_owned(), .. }, Movie { title: "Star Wars".to_owned(), year: None }, )