pattern
Rust Destructure a tuple into bindings
A pattern describes the shape to extract. Tuple destructuring names individual components at once, rather than repeatedly accessing numeric fields. Expected output (not executed): 12, 7 Why: The two positions become independent local integer bindings. Common mistake: The number of tuple fields must match unless you use a suitable rest pattern.
Formal Syntax & Structure
rust syntaxrust
let (first, second) = tuple;Working Example
Example Snippetrust
fn main() { let location = (12, 7); let (x, y) = location; println!("{x}, {y}");}