Ultimate Rust Crash Course !full! < macOS >

let s = String::from("hello world"); let hello = &s[0..5]; // type: &str let world = &s[6..11]; String literals are &str (immutable slices). struct User active: bool, username: String, sign_in_count: u64,

fn main() { let user1 = User active: true, username: String::from("rustacean"), sign_in_count: 1, ; println!("{}", user1.username); } struct Color(i32, i32, i32); let black = Color(0,0,0); Methods (impl block) impl User { fn display(&self) { println!("{} active: {}", self.username, self.active); } } user1.display(); 12. Enums & Pattern Matching Enums are Rust’s way of saying “one of these variants.” ultimate rust crash course

let f = File::open("hello.txt").unwrap(); let f = File::open("hello.txt").expect("Failed to open hello.txt"); Propagate errors with ? operator (inside function returning Result ): let s = String::from("hello world"); let hello = &s[0

enum Result<T, E> Ok(T), Err(E),