-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make new and default implementation not depend on random state
This oddly fixes issue #148. I tried to compose a set in a set. Which failed miserably, because the HashSet would not have the same hash, because of the random state hasher implementation. This was done to prevent hand crafted key DOS attacks. To get things working, you can build hash maps with exactly the same deterministic hasher. This becomes error prone and inconvenient quite quickly. Sprinkeling ::with_hasher() everywhere. So this commit generalizes the ::new() and Default implementation over the hasher (S) implementing Default and BuildHasher traits. This makes it possible to instantiate the RandomState specific implementations in the root lib module, while keeping the default(), new() and unit() implementations general for each hasher. So if I want a MyHashmap<K,V> with a SpecificHasher implementing Default: type MyHashMap<K,V> = im::hashmap::HashMap<K,V,SpecificHasher>; Then all functions still work for the different hasher. I would then also have to reimplement the macros. But that is fine.
- Loading branch information
Daan Oosterveld
committed
Nov 19, 2020
1 parent
3f4e01a
commit 645a1ae
Showing
5 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters