Explain "It is a logic error ... " in HashMap, BTreeMap and others #80657
Labels
A-collections
Area: `std::collection`
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
In various pieces of the documentation that talk about "It is a logic error ...", mostly to change the keys of HashMap/Sets and BTreeMap/Sets, using RefCells or hashing functions which change their behaviour based on global variables.
What does "it is a logic error ... " mean? With some brief playing it appears (to me) that it puts the datastructure in an inconsistent state, where future calls to any member function can return nonsense values.
It appears (from what I can tell) there is no unsafe behaviour, and it isn't possible to make the datastructures call
panic
, but I would be happy to say they could panic (saying they won't means checking they can't when someone has already done something stupid).So, I suggest a short extra sentence which just says "These logic errors can lead to incorrect results and panics but not unsafe behaviour"
The text was updated successfully, but these errors were encountered: