1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2024-12-21 16:08:09 -05:00
rustlings/solutions/01_variables/variables3.rs

16 lines
393 B
Rust
Raw Normal View History

2024-07-04 07:38:35 -04:00
#![allow(clippy::needless_late_init)]
2024-05-20 19:47:57 -04:00
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}");
2024-07-04 07:38:41 -04:00
// It is possible to declare a variable and initialize it later.
2024-05-20 19:47:57 -04:00
// But it can't be used before initialization.
let y: i32;
y = 42;
println!("Number {y}");
}