Define data inside enum variants using tuple or struct syntax, then access it via pattern matching with match.
enum Message {
Quit,
Move { x: i32, y: i32 },
Write(String),
ChangeColor(u8, u8, u8),
}
fn main() {
let msg = Message::Write(String::from("hello"));
match msg {
Message::Write(text) => println!("Text message: {}", text),
Message::Move { x, y } => println!("Move to ({}, {})", x, y),
Message::ChangeColor(r, g, b) => println!("Change color to ({}, {}, {})", r, g, b),
Message::Quit => println!("Quit"),
}
}