Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(primitives): implement map module #743

Merged
merged 11 commits into from
Sep 25, 2024
Merged

feat(primitives): implement map module #743

merged 11 commits into from
Sep 25, 2024

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Sep 20, 2024

Add mod map in alloy-primitives which contains type aliases for different hashmaps with different hashers.

Contains a set of:

  • hashmap, hashset (from hashbrown or std); indexmap, indexset
  • default hasher, fxhash
  • fixed-bytes hasher for FixedBytes and aliases

Default hasher is: fxhash random seed ("map-fxhash" + "std" + "rand") > fxhash no seed ("map-fxhash") > std > hashbrown default hasher
(can't have random seed in no_std AFAICT)

New features:

  • "map" - enables the module
  • "map-fxhash" - switches default hasher to fxhash and re-exports
  • "map-hashbrown" - forces HashMap to be a re-export of hashbrown instead of std (default for no_std)
  • "map-indexmap" - indexmap re-exports
  • "nightly" - passes through "nightly" to dependencies, useful for enabling override of Hasher::write_length_prefix

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, this should be useful

the stable build error looks odd

@DaniPopes
Copy link
Member Author

It's due to "nightly" feature due to --all-features on stable

Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

Easier to change the implementation later on.
Ideally this is only a depedencny if `not(feature = "std")` but this is
currently not something you can have with cargo features.
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.

4 participants