Hi!
Suppose that I have a vector or enums, some variants have fields and some don't. How do I check if a vector contains any variations of a specific enum field regardless of any value it might contain? For instance, in the following example, How do I check if spells
contains Shield
without knowing that the value of Shield
is 10
? Thanks
#[derive(Ord, PartialOrd, Eq, PartialEq, Hash)]
enum Spell {
MagicMissile,
Shield(i32),
}
fn main() {
let spells = vec![Spell::MagicMissile, Spell::Shield(10)];
println!("{}", asd.contains(&Spell::MagicMissile));
println!("{}", asd.contains(&Spell::Shield(0)));
println!("{}", asd.contains(&Spell::Shield(10)));
}