Common Programming Concepts

Constant

Shadowing

let spaces = "    ";
let spaces =. spaces.len();

Ex. (mut; will cause compile-time error)

let spaces = "    ";
spaces = spaces.len();

Data Types

integers, floating-point, Booleans, and chars

Length Signed Unsigned
8-bit i8 u8
16-bit i16 u16
32-bit i32 u32
64-bit i64 u64
128-bit i128 u128
Architecture-dependent isize usize
Number literals Example
Decimal 98_222
Hex 0xff
Octal 0o77
Binary 0b1111_0000
Byte (u8 only) b'A'
let a: [i32; 5] = [1, 2, 3, 4, 5];
let b: [3; 5]; // [3, 3, 3, 3, 3]

Function

The order of function definitions doesn't really matter. Say fuction1() calls function2(). As long as function2() can be "seen" by function1() within the scope, function2() definition can be written before or after fuction1()

functions can have `parameters, which are special variables that are part of a function's signature.

Technically, the concrete values for the parameters are called arguments

In function signatures, you must declare the type of each parameter

In Rust, the return value of the function is synonymous with the value of the final expression in the block of the body of a function.