Ultimate - Rust Crash Course
use std::fs::File; use std::io::ErrorKind; fn main() let greeting_file_result = File::open("hello.txt"); let greeting_file = match greeting_file_result Ok(file) => file, Err(error) => match error.kind() ErrorKind::NotFound => match File::create("hello.txt") Ok(fc) => fc, Err(e) => panic!("Problem creating the file: :?", e), , other_error => panic!("Problem opening the file: :?", other_error);
enum IpAddrKind V4(u8, u8, u8, u8), V6(String), ultimate rust crash course
let home = IpAddrKind::V4(127,0,0,1); let loopback = IpAddrKind::V6(String::from("::1")); Rust has no null . Instead: Option<T> . fn main() let greeting_file_result = File::open("hello.txt")
A trait defines shared behavior.
Rust is famously loved for its memory safety, blazing speed, and excellent tooling. It’s also famously feared for its borrow checker and steep learning curve. This crash course strips away the complexity, giving you a mental model of Rust that works. match error.kind() ErrorKind::NotFound =>