28
you are viewing a single comment's thread
view the rest of the comments
[-] d_k_bo@feddit.org 4 points 2 years ago* (last edited 2 years ago)

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 },
)

[-] SorteKanin@feddit.dk 2 points 2 years ago

Think you would need Movie { title: "Star Wars".to_owned(), .. }, the .. is mandatory.

[-] d_k_bo@feddit.org 2 points 2 years ago

Thanks, that was an oversight on my part.

this post was submitted on 08 Dec 2024
28 points (96.7% liked)

Rust

8270 readers
25 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS