Trait objc2::mutability::HasStableHash
source · pub unsafe trait HasStableHash: Sealed { }
Expand description
Marker trait for classes whose hash
and isEqual:
methods are stable.
This is useful for hashing collection types like NSDictionary
and
NSSet
which require that their keys never change.
This is implemented for classes whose ClassType::Mutability
is one of:
Since all of these do not use interior mutability, and since the hash
and isEqual:
methods are required to not use external sources like
thread locals or randomness to determine their result, we can guarantee
that the hash is stable for these types.
§Safety
This is a sealed trait, and should not need to be implemented. Open an issue if you know a use-case where this restrition should be lifted!