--- title: Patterns description: Pattern matching with literals, tuples, structs, named tuples, wildcards, and mutable bindings. icon: Split --- ```mist // Literal patterns match x { 1 => "one", 2 => "two", _ => "other", } // Tuple patterns let (a, b) = (1, 2); // Struct patterns match value { Point { x, y } => x + y, Point { x: 0, y } => y, _ => 0, } // Named tuple patterns (newtype) let MyType(value) = my_var; // Wildcard / rest let _ = get_side_effect(); match x { 1 => expr, .. => expr, // rest / etc } // Mutable binding in pattern let mut x = 42; match ref_to_option { Some(mut value) => value += 1, None => {}, } ```