rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

variables3.rs (393B)


      1 #![allow(clippy::needless_late_init)]
      2 
      3 fn main() {
      4     // Reading uninitialized variables isn't allowed in Rust!
      5     // Therefore, we need to assign a value first.
      6     let x: i32 = 42;
      7 
      8     println!("Number {x}");
      9 
     10     // It is possible to declare a variable and initialize it later.
     11     // But it can't be used before initialization.
     12     let y: i32;
     13     y = 42;
     14     println!("Number {y}");
     15 }