It looks like you are asking how to relate a value in the first case. If so, you can use this:
match get_image_type() {
If you also want to get the bound value outside the match statement, you can use the following:
let matched = match get_image_type() { Some(h @ ImageType::Png) | Some(h @ ImageType::Jpeg) => {
In this case, it might be better to just let h = get_image_type() and then match h (thanks to BHustus ).
Note the use of the h @ <value> syntax to bind the variable name h to a matching value ( source ).
Sรธren mortensen
source share