#[derive(Debug, Clone)] enum Msg { Quit, Move { x: i32, y: i32 }, Change(i32, i32, i32), Error, } impl Msg { fn show(&self) { match self { Msg::Quit => println!("quit"), Msg::Move { x, y } => println!("move {} {}", x, y), Msg::Change(x, y, z) => println!("change {} {} {} ", x, y, z), _ => println!("_"), } } } fn main() { let q = Msg::Quit; q.show(); let e = Msg::Error; e.show(); let m = Msg::Move { x: 1, y: 2 }; m.show(); let c = Msg::Change(1, 2, 3); c.show(); }