This is an unpopular limitation of the constraint system. You cannot restrict the type of value in accordance with specific operations on it, if they are not defined in the interface. Thus, you cannot restrict the definitions of statements, since they will not be defined for all types of values, and the restriction struct allows you to pass any type of value.
struct A { }
This is not defined == , and yet your restriction says that you would be happy to accept it. Therefore, you cannot use == .
The reason it differs from reference types is because the definition == (identity comparison) is available to them.
The == implementation on enum is close enough to the Equals implementation that your workaround is ok.
Compare with the situation for > with numeric types! There is no such workaround. Standard numbers do not have an interface with methods such as GreaterThan , etc.
source share