-
Notifications
You must be signed in to change notification settings - Fork 56
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
Fields with reserved names #84
Comments
Leading underscore has a specific meaning in Rust, namely that it suppresses warnings about something going unused. So, I'd suggest trailing underscore. |
Personally I prefer a trailing underscore. The convention in the compiler (which faces this issue a lot) is to modify the keyword ( We've shied away from naming conventions here, we prefer to concentrate on purely formatting issues. This does seem like a reasonable thing to cover in the naming section of the style guide though. |
C# allows you to use, |
I don't think it is - |
Just to point out that a trailing underscore is also autocomplete-friendly for users expecting to find a function/member with a name that coincides with a reserved keyword. |
If I do serialization of the JSON object
{"type": "foo", "count": 3}
, the struct would have to look like that to match the field names:The thing is that
type
is a reserved keyword, so it can't be used.Of course I can use the Serde rename feature. But is there a convention on how to call the field instead, e.g. trailing slash (
type_
), leading slash (_type
) or modification (typ
ortipe
)?The text was updated successfully, but these errors were encountered: