summaryrefslogtreecommitdiff
path: root/solutions/01_variables/variables3.rs
blob: 15f6557ce78e2ea64995b7187f9e53eb2d3015cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#![allow(clippy::needless_late_init)]

fn main() {
    // Reading uninitialized variables isn't allowed in Rust!
    // Therefore, we need to assign a value first.
    let x: i32 = 42;

    println!("Number {x}");

    // It is possible to declare a variable and initialize it later.
    // But it can't be used before initialization.
    let y: i32;
    y = 42;
    println!("Number {y}");
}