How to not do anything on the "rest case" when matching a string?
Solution 1:
let some_u8_value = 0u8; match some_u8_value { 1 => println!("one"), 3 => println!("three"), 5 => println!("five"), 7 => println!("seven"), _ => (), }
The () is just the unit value, so nothing will happen in the
_
case. As a result, we can say that we want to do nothing for all the possible values that we don’t list before the_
placeholder.
You can also use empty block expression {}
.