元组
元组可以在 match 中解构,如下所示:
fn main() {let triple = (0, -2, 3);// 试一试 ^ 将不同的值赋给 `triple`println!("Tell me about {:?}", triple);// match 可以解构一个元组match triple {// 解构出第二个和第三个元素(0, y, z) => println!("First is `0`, `y` is {:?}, and `z` is {:?}", y, z),(1, ..) => println!("First is `1` and the rest doesn't matter"),// `..` 可用来忽略元组的其余部分_ => println!("It doesn't matter what they are"),// `_` 表示不将值绑定到变量}}
