Why is camel case a requirement?


Hi all,

In the above screen shot I defined a user defined data type using struct named “params”, but while compilation I got a warning saying that it should have Camel case.

Saw that requirement in the rust book documentation too (https://doc.rust-lang.org/book/structs.html).

I was wondering why do we have to write it in this manner? Any specific reason behind this?


This is just a convention: CamelCase for types, snake_case for functions. It’s only a warning and you can shut if off (or ignore it). But doing so will make your code look different to code from other projects if that matters. You may, however, run into code that doesn’t follow the convention when you are doing Foreign Function Interface (ffi) work where you import types and functions from other languages, like C.

The reason behind it is more about choosing one single style rather than any particular style that’s best. Getting everyone to use one ok solution is better than wasting time discussing the merits of various different styles which may have a 0.01% improvement.


I kinda like this styling and +1 for unified single style. I totally agree with you about wasting time to discuss the different merits of various style.

Thank you @ehiggs for fast reply 7 clarification.


I believe that the main reason that there is a difference between the suggested typing for types and functions is to make it more clear what kind of things your names represent. Making a choice here is the most important here. what choice then indeed does not really matter; the Law of Triviality that @ehiggs mentioned already applies.

Making this choice language-wide means that we won’t encounter problems akin to the problems of Endianness when interfacing with other libraries following different rules later on.