We can use any names as variable names, however, there are some rules we should follow:
-
Rust is a case sensitive language. Hence, lowercase variables and uppercase variables are different. For example:
age
is different fromAGE
name
is different fromName
-
Variables must start with either a letter or an underscore. For example,
- Variable names can only contain letters, digits and an underscore character. For example,
- Use underscore if we need to use two words as variable names. For example,
Note:
Always try to give meaningful names to your variables. For example,
name
,age
,number
are better names thann
,ag
,nm
.