Back to Browse

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

261 views
Dec 4, 2020
11:32

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: https://doc.rust-lang.org/reference/types/numeric.html 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

Download

1 formats

Video Formats

360pmp414.8 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

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