However, the match expression can be a bit wordy in a situation in which we care about only one of the cases.
For this situation, Rust provides if let.
6.4 if let
1 2 3 4 5 6 7 8 9 10
if we only care about one of the case, we can use"if let" let some_u8_value = Some(0u8); match some_u8_value { Some(3) => println!("three"), _ => (), } 等价于 ifletSome(3) = some_u8_value { println!("three"); }