视频地址
头条地址:https://www.ixigua.com/i6765442674582356483
B站地址:https://www.bilibili.com/video/av78062009?p=1
网易云课堂地址:https://study.163.com/course/introduction.htm?courseId=1209596906#/courseDetail?tab=1
讲解内容
例子:
let some_value = Some(10);
match some_value {
Some(3) => println!("three"),
_ => println! (“other”),
}
但是,当我们只关心等于3时的情况,用match就感觉代码太多了,那么我们就可以使用if let:
if let Some(3) = some_u8_value {
println!("three");
} else {
println! (“other”);
}