-
Couldn't load subscription status.
- Fork 13.9k
Description
The standard library type std::sync::OnceLock is Eq but not Hash. From a theoretical and practical perspective, it should probably be both or neither.
The argument for neither is that the result of Eq can change because of a different thread as soon as it is returned. Similarly, the value of Hash can change between comparison of the Hash and a follow up comparison with Eq. Both of these are expected short-comings of types that can be changed by other threads.
The argument for both is that Hash is fundamentally a property related to equality and not rules out usages in containers where there are some external invariants that guarantee the desired behavior.