Skip to content

fix: ensure consistent hashing for specialized owned and reference types#286

Open
agmbk wants to merge 1 commit intotkaitchuck:masterfrom
agmbk:master
Open

fix: ensure consistent hashing for specialized owned and reference types#286
agmbk wants to merge 1 commit intotkaitchuck:masterfrom
agmbk:master

Conversation

@agmbk
Copy link

@agmbk agmbk commented Feb 6, 2026

Ensure that String and &String compute identical hashes, as well as OsStr and Path.

To resolve this, a recursive macro implements up to five &&&&& for each specialized type. String types are also included.

Previously the tests were passing only because a known type was used (ex. str::get_hash). This bypassed the type resolution occurring in generic interfaces, and missed the fact that references &String type fallback to the default implementation.

This is now verified by testing on the hash_one method that lets the compiler infers the type.

Ensure that `String` and `&String` compute identical hashes, as well as `OsStr` and `Path`.

To resolve this, a recursive macro implements up to five `&&&&&` for each specialized type. `String` types are also included.

Previously the tests were passing only because a known type was used (ex. `str::get_hash`). This bypassed the type resolution occurring in generic interfaces, and missed the fact that references `&String` type fallback to the default implementation.

 This is now verified by testing on the `hash_one` method that lets the compiler infers the type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant