一、模式基本概念
二、模式可辩驳性
三、模式语法
fn main() {
let x = Some(5);
let y = 10;
match x {
Some(50) => println!("Got 50"),
// 匹配到5 所以在这个作用域y=5
Some(y) => println!("Matched,y={:?}",y),
_ => println!("Default case,x={:?}",x),
}
println!("at the end:x={:?},y={:?}",x,y);
}
上面匹配的是[1,5] 左闭右闭区间