We can use any names as variable names, however, there are some rules we should follow:

  1. Rust is a case sensitive language. Hence, lowercase variables and uppercase variables are different. For example:

    • age is different from AGE
    • name is different from Name
  2. Variables must start with either a letter or an underscore. For example,

let age = 31;     	// valid and good practice
let _age = 31;    	// valid variable 
let 1age = 31;    // inavlid variable
  1. Variable names can only contain letters, digits and an underscore character. For example,
let age1 = 31;        // valid variable
let age_num = 31;     // valid variable
let s@lary = 52352;   // invalid variable
  1. Use underscore if we need to use two words as variable names. For example,
let first name = "Jack";    // invalid variable
let first_name = "Jack";    // valid variable
let first-name = "Jack";    // invalid variable

Note:

Always try to give meaningful names to your variables. For example, name, age, number are better names than n, ag, nm.