BASIC SYNTAX CHEATSHEET
1..101 // RangeInclusive<i32> 1 till 100
1..=100 // RangeInclusive<i32> 1 until 100
[..] // FullRange
[3..] // Index 3 until end
[..5] // Index 0 until Index 5 (not included)
[..=5] // Index 0 until Index 5 (included)
// basic print, no interpolation
println!("Hello World");
// basic interpolation
println!("x = {}, y = {}", 12, 2);
// placeholder trait (EASY DEBUGGING)
println!("display: {:?}", any_var);
// named interpolation
println!("hello {name}", name="thomas");
STRINGS
let str_constant = "Hello World"; // cannot be changed
let str = String::new("hello world"); // if you want to change value
// methods
str.push('a'); // push character
str.push('\\u{1f600}'); // (unicode)
str.push_str("appeneded text"); // append to string
str.len(); // length of string
str.replace("World", "There"); // replaces world with there
str.is_empty(); // returns bool (=> false)
str.contains("World"); // returns bool (=> true)
str.split_whitespace(); // ["Hello", "World"]
str.split(" "); // ["Hello", "World"]
str.chars(); // ["H","e","l","l","o"," ","W",...]
// ❌ str.split("") does NOT work
ASSERTIONS
assert_eq!(val1, val2); // returns bool
TYPE CONVERSION
let num_usize: usize = num as usize;