Feature Request Support Camel Case with Underscore as a Standard Style

Request: Support Came_Case_With_Under_Scores for CamelCase names in structs and enums.

These give a good middle ground between readability and our community language standards. This would be a minor change to the parser and help so many of us with eyesight issues.

The definition of CamelCase is that each first letter of a word is capitalized to denote them, there is no reason this should be exclusive of special characters that are normally allowed in variable names. The allowance of numbers and not underscores sends mixed signals.

The language supports any identifier style you like, as long as it follows Unicode XID. The only enforcement comes through style lints, but you can #[allow(nonstandard_style)].


I think there are code editors that have various "glasses" modes, which might be configurable to visually present such code differently in a fashion you find more readable. And as an added advantage, such presentation could visually distinguish between the underlying source and the visual presentation, to avoid obscuring what the underlying name is.

I wonder if this might be possible with a VSCode extension, for instance.

That would help solve this issue with everyone's code, rather than just the projects using this specific non-default style.


Thank you,

I see, perhaps the better wording would be to make underscored CamelCase a standard style.


Didn't know these things exist. Let me know if you see any for VSCode, I will look around couldn't find anything after searching for a while. This might be due to the "code lens" feature they have.

Maybe Color Identifiers would be helpful to you? I found that via vscode#132689, which also lists a lot of prior art plugins for other editors.

1 Like

Coming back here as I was writing this code and I really can see how underscores aren't supported as a default style when they help so much:

image VS

This is still UpperCammelCase but without the "no underscore restriction."

The point of a standard default style is to have a single preferred way to write names. Underscores being optional would create two different ways to write the same name (with and without the underscores) which would make this pointless.

What's wrong with #[allow(nonstandard_style)]?