Skip to content

Support default field values #1386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Nadrieril opened this issue Apr 1, 2025 · 0 comments
Open

Support default field values #1386

Nadrieril opened this issue Apr 1, 2025 · 0 comments

Comments

@Nadrieril
Copy link
Collaborator

Rust should soon support the following syntax (rust-lang/rust#132162):

#[derive(Default)]
struct Pet {
    name: Option<String>, // impl Default for Pet will use Default::default() for name
    age: i128 = 42, // impl Default for Pet will use the literal 42 for age
}

This will require special handling as such fields are not desugared to anything else in the THIR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant