Skip to Content

Ultimate Rust Crash Course //top\\ < Quick ● >

Example: reading a file

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

cargo new hello_rust cd hello_rust cargo run Inside src/main.rs : Example: reading a file fn main() { let

enum IpAddrKind V4(u8, u8, u8, u8), V6(String), } struct Color(i32