Let say for example that this is a Json parser and to represent each variant of the possible data which contains I use an enum.
#[derive(Copy, Clone, PartialEq)]
enum JsonObject {
Invalid,
Null,
Bool(boo),
/// etc
}
Now the in some part of the code I compare two JsonObjects
let type1 = JsonObject::Bool(true);
let type2 = JsonObject::Bool(false);
if type1 == type2 {
// do stufff
}
The problem is that type1 != type2
because JsonObject::Bool(true) != JsonObject::Bool(false)
, What I want is that the enum does not compare the inner data of the variant and just the variant itself.
JsonObject::Bool(_) == JsonObject::Bool(_)