`std::sync::OnceLock` is `Eq` but not `Hash`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names std::sync::OnceLock but no files or tests. Begin by locating its Eq implementation and nearby standard-library trait tests, then determine whether the intended resolution is to add Hash or remove Eq; done requires an explicit API decision and matching regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100