Skip to content

feat(primitives): implement map module#743

Merged
DaniPopes merged 11 commits intomainfrom
dani/primitives-map
Sep 25, 2024
Merged

feat(primitives): implement map module#743
DaniPopes merged 11 commits intomainfrom
dani/primitives-map

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
Contributor

@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