Skip to content
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

Support enum defaults #247

Open
Manishearth opened this issue Aug 31, 2022 · 1 comment
Open

Support enum defaults #247

Manishearth opened this issue Aug 31, 2022 · 1 comment
Labels
A-attributes Area: configurability via attributes enhancement New feature or request

Comments

@Manishearth
Copy link
Contributor

Manishearth commented Aug 31, 2022

It should be possible to do:

enum SignDisplay {
     #[default]
     Auto,
     Always,
     OnlyNegative,   
}

such that null coeces to Auto. This would translate to a default constructor in C++, and would allow null/undefined in JS (so you can omit fields of options bags)

Ideally DiplomatOptional (#132) gets this too, or at least supports this as #[permit_default]

@Manishearth
Copy link
Contributor Author

@sffc and I discussed this a bit and 99% of the time these things show up in struct fields where we should just support Option instead.

#246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: configurability via attributes enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant