Upper and Lower Case
When to use upper case and when to use lower case in Rust is guided by pretty strong conventions. Convention here means that you’re not forced to do it, but it’s widely accepted that you should follow these rules.
-
Variable and function names start with a lower case. If you have multiple words, you separate them with an underscore. For example,
first_name
. This is known as “snake case” because it’s kind of like a snake slithering on the ground. -
Types (besides primitives like
i32
andstr
) should start with a capital letter, and each new word should have another capital letter. For example,FirstName
. This is known as “upper camel case,” since it starts with an upper case and each new word kind of looks like a camel’s hump.
If you use the wrong capitalization scheme, you’ll get a warning from the compiler encouraging you to change it.