Power of Enums
Enums in Rust are much more powerful than in other languages. They can hold data.
rust enum Message { Quit, Move { x: i32, y: i32 }, Write(String), }
The match Operator
match is a control flow construct that allows you to compare a value against a series of patterns. It is exhaustive—you must handle every possible case.
rust match message { Message::Quit => println!("Quitting"), Message::Write(text) => println!("Text: {text}"), _ => (), // Handle everything else }