Install Rust
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | shUpdate Rust
rustup updateCreate new project
cargo new myappcd myappcargo run
Compile and run
cargo run (will compile and run main.rs)
build release bin
cargo build --releaseConditionals
if / else
fn main() { let n = 5;AND, OR
if n < 10 && n > 10User Input
use std::io;fn main {install cargo pkgs
vi Cargo.toml
Update dependencies
cargo update
Variables
new mutable string
let mut name = String::new()
name = "Joe"
name = "Frank"
bool
char
f32,f64 // 32bit, 64bit float
i8,i16,i32,i64,i128 // signed int
i8 = -127 to 127
i16 =
u8,u16,u32,u64,u128 //unsigned 0 to 255, no negative
Integers
signed/unsigned integers (signed can be negative)
8 bit = i8 (-127 to 127), u8 (0 to 255)
16 bit = i16 (, u16 (-
32 bit = i32, u32
64 bit = i64, u64
128 bit = i128, u128
arch = isize, usize
convert String to Int
let mut guess = String::new();
guess = "23"
Math operations