fn longest<'a>(x: &'a str, y: &'a str) -> &'a str if x.len() > y.len() x else y
largest
let mut s = String::from("hello"); change(&mut s); 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 longest<'a>(x: &'a str, y: &'a str) ->
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.” (x: &'a str
Early return uses return keyword.