Hi folks,
a feature request, I tried to open an issue, and it pointed me here.
Let's add a function:
impl RandomState {
const fn new_non_random() -> RandomState { ... }
}
Create a "random state" which is not random, just some unspecified constants.
There are reasons to do that:
- make possible to make
HashMap
deterministic, which might be useful in certain situations even at risk of DOS (for example, when debugging tests, to make test outputs repeatable to debug them easier: if test fails on fifth iteration, we can check third break on each run) - make
HashMap::with_hasher
const fn. Which is useful to putHashMap
in a static variable (note hashbrown HashMap constructor is already const fn)
The issues mentioned above can be solved by implementing own random state object (and making with_hasher
const fn), but that would complicate the client code: will need to propagate that type parameter everywhere. And public API will be worse.
These are trivial to implement obviously. Are there reasons not to?