this post was submitted on 08 Dec 2024
30 points (96.9% liked)

Rust

6119 readers
2 users here now

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

Wormhole

[email protected]

Credits

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

founded 2 years ago
MODERATORS
top 6 comments
sorted by: hot top controversial new old
[–] robinm 5 points 1 week ago

It's really nice to see this RFC progress

[–] snaggen 5 points 1 week ago

I think this would be a nice improvement to reduce boiler plate.

[–] [email protected] 4 points 1 week ago

Hmmm... I guess I don't see why not?

[–] [email protected] 4 points 1 week ago* (last edited 1 week ago) (1 children)

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

[–] [email protected] 2 points 1 week ago (1 children)

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

[–] [email protected] 2 points 1 week ago

Thanks, that was an oversight on my part.