println!("Hello World!");

Formatted Printing format!: write formatted text to String print!: same as format! but the text is printed to the console (io::stdout). println!: same as print! but a newline is appended. eprint!: same as print! but the text is printed to the standard error (io::stderr). eprintln!: same as eprint! but a newline is appended.

Variables and Mutability

By default variables are immutable.

To “change” a immutable variable, you must shadow it:

let x = 5;
let x = x + 1;
let x = 4;
// cannot do x = 3.
 
let mut y = 3;
y = 2;

Tuples:

let x: (i32, f64, u8) = (500, 6.4, 1); 
let five_hundred = x.0; 
let six_point_four = x.1; 
let one = x.2;

Loops and stuff

For loops:

    let a: [i32; 4] = [5, 10, 15, 20];
    for i in 0..a.len() {
        println!("i: {i}");
    }
	for i in (0..a.len()).step_by(2) {
        println!("i: {i}");
    }