-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
std::hash::Hash documentation should suggest that the hash data should be prefix-free #89429
Copy link
Copy link
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
As discussed at Why does
str.hash(…)pass an extra byte to the Hasher?: the code ofimpl Hash for &strspecifically passes an extra 0xFF byte to the Hasher, so that values like("ab", "c")and("a", "bc")hash differently (added in 6066118).This is a subtle property of hashing and should probably be mentioned in the documentation for
Hash— particularly as the documentation forHasheralready says “you cannot assume, for example, that awrite_u32call is equivalent to four calls ofwrite_u8” which could be sloppily interpreted as an expectation that a goodHasherimplementation will handle “quoting” of sequential calls itself.If an implementor of
Hashfails to have this property, it could compromise the hash-DoS resistance that Rust tries to offer by default.@rustbot labels: +A-docs +T-libs-api +C-enhancement