I am running into this error:
error: operator != not allowed for type ...
and I have no idea if there is an expected method I need to implement to be able to use != (and == etc) with my custom type.
I am running into this error:
error: operator != not allowed for type ...
and I have no idea if there is an expected method I need to implement to be able to use != (and == etc) with my custom type.
Check out std.meta.eql() but be aware of the limitations:
You can use equality operators for packed structs. This is especially useful for simple wrapper types and only contain a single integer, as the packed nature doesn’t change anything in this case.
Zig does not have operator overloading, so it isn’t possible to re-define == and != for an arbitrary custom type.
You will instead use functions to do comparisons,
May I ask in which context you need an equality (or equivalence?) comparison?
Such a comparison could have different meanings: