I have an enum:
enum T {
A(String),
}
I want to match a variable of this enum, but this code doesn't work:
match t {
T::A("a") => println!("a"),
T::A("b") => println!("b"),
_ => println!("something else"),
}
I understand that I can do this, but it is so verbose in my opinion:
match t {
T::A(value) => match value.as_ref() {
"a" => println!("a"),
"b" => println!("b"),
_ => println!("something else"),
},
}
Is there a shorter way to do this?