filmov
tv
Declaring Variables, Numeric Types, Read User inputs | Rust Programming | Kovolff

Показать описание
When you define a variable in Rust
i.e. let my_age: i64 = 29;
Rust sets this variables by default as immutable
To set a mutable variable, you need to add the keyword mut in your declaration,
i.e. let mut my_age: i64 = 29;
The list of numeric types in Rust can be found here:
To get user input via the terminal
1. We need to import a package allowing us user input,
i.e. use std::io;
2. Create a vraibel to take the user input
i.e. let mit user_age = String::new();
3. Get the input
io::stdin().read_line(&user_age).expect(“No age was read”)
#rust #variables #programming
i.e. let my_age: i64 = 29;
Rust sets this variables by default as immutable
To set a mutable variable, you need to add the keyword mut in your declaration,
i.e. let mut my_age: i64 = 29;
The list of numeric types in Rust can be found here:
To get user input via the terminal
1. We need to import a package allowing us user input,
i.e. use std::io;
2. Create a vraibel to take the user input
i.e. let mit user_age = String::new();
3. Get the input
io::stdin().read_line(&user_age).expect(“No age was read”)
#rust #variables #programming