In the documentation for
Hashable.hash(into:) we currently have the following line:
The components used for hashing must be the same as the components compared in your type’s
IIRC, back when
Hashable was simply based on the
hashValue requirement, the semantic "rule" of the protocol was something like "values which return
val1 == val2 must also return
val1.hashValue == val2.hashValue," which is a notably weaker guarantee.
In particular, the current semantics of
Hashable would seem to prohibit implementing a sort of "fast path" version of
hash(into:) which only hashes a subset of the components used for
Hashable documentation features a somewhat confusing statement (emphasis added):
Hashing a value means feeding its essential components into a hash function, represented by the
Hashertype. Essential components are those that contribute to the type’s implementation of
Equatable.Two instances that are equal must feed the same values to
hash(into:), in the same order.
The final sentence seems in-line with the former, looser semantics for
Hashable, but it is seemingly contradicted by other elements of the documentation.
Are the newer, stricter semantics of
Hashable meant to be interpreted as I've understood them? If so, why the change?