Make new and default implementation not depend on random state #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Great library, I use it often.
I have found a small composition problem related to #148
I was unable to compose a set as a key. Looking further it was due to the random state hashing which is a security concern. I think that is a reasonable security concern if the data structures are exposed directly. But it does preclude the hash map and hash set to be composed with itself if the default hasher is used.
So basically it is not a problem the RandomState is the default, but rather swapping it with another hasher which is deterministic. The intended goal of this commit is keeping that use case readable.
To make it somewhat more convenient to have hash sets and maps with a different hasher, I have generalized the implementations of new() and unit() such that they work with hashers which implement default. RandomState implements that trait as well, so it fits nicely.
In that case a specific version of a hashmap can be instantiated by a type definition, while keeping the Default trait and new and unit implementations:
type MyHashMap<K,V> = im::hashmap::HashMap<K,V,MySpecificHasher>;
Let me know what you think.