Run the following program using Stable or Nightly:
The compiler tells us:
warning: type `userData` should have a camel case name such as `Userdata`
--> src/main.rs:1:1
|
1 | / struct userData
2 | | {
3 | | name: String,
4 | | age: u8,
5 | | weight: f32,
6 | | height: f32
7 | | }
| |_^
|
= note: #[warn(non_camel_case_types)] on by default
This is incorrect/confusing in 3 ways:
1.) userData _is_ in fact camelCase.
2.) UserData would be PascalCase and this is the convention I've seen
3.) Userdata is neither... So even if for some strange reason we're considering PascalCase as camel case, the recommendation is neither.
Ah, good catch: it's been noted in the style guide that "upper camel case" is a better term, as it's not so ambiguous (the term "camel case" is variably used for ThisStyle and thisStyle). The lint name itself (non_camel_case_types) is probably fine, but it would be good to clarify "upper camel case" in the lint message.
Userdata is neither...
Userdata is upper camel case — but it's considered to have a single component (i.e. userdata as a single word). I think it would be reasonable not to lowercase mid-word capitals like this.
This should be very straightforward to fix — you're welcome to open a pull request fixing this! (If you search for the message, you should find the location to make the change.)
@varkor Do we want to specify Pascal Case which _always_ exclusively refers to upper camel case to be least ambiguous? Or do we want to stick to "upper camel case?"
There was actually a whole discussion on this topic earlier this year and it was decided that "upper camel case" was clearer (though it seems no-one thought to change the compiler lints), so let's go with that.
Great, will make a PR tonight, thanks.
Most helpful comment
Great, will make a PR tonight, thanks.