Use match on hashmap keys?

#1

Is it possible to have each arm in a match statement be a potential key in a hashmap?

I’d love to do this matching on clap arguments here

#2

That should do it:

for (key, value) in hashmap.iter() {
    match key {
        "foo" => {},
        "bar" => {},
        _ => {},
    }
}
1 Like