Learn Rust Flashcards
Garbage Collection
None - frees up memory automatically
Cargo
cargo new demoName cargo build cargo build --release cargo run --release cargo watch -x run
Scalar Types: integer, floating point numbers, boolean, , characters
large whole number, floating point = decimals, boolean: true/false; characters:
tuple type
(5, 5.0, “chris”). let (x, y, z) = tuple | x = 5
fn hello_world(name: &str) { println!("hello {}", name); }
need & to know length of string else it wont compile
i8
8 bit integer
::
bind method to call that library
u64
unsigned integer, number cant be negative
float
f32 floating number 6.7 with decimal
if else statement
if n < 30 {} else {} | ==; !=; ;
enum
enum Name {variance} eg {Up, Down}. let test:Name = Name::Up
constants
const Name: u8 = 20; name and type. for n in 1..Name {}
tuples
bunch of variables in 1 place. let tup1 = (20, “test”, 21.1);
code block
fn main(){ let x = 10; {inside here can access outside x } outside here cant access inside {} }
shadowing
let mut x = 10; { let x = 15; } x is 10 here. Inside code block is isolated.