Open
Description
Overview
I want to suggest an improvement for the library -- the ability to use custom hashes (specifically interested in ahash).
Why?
The standard library uses a sip hash, which is protected against various types of attacks on hash tables, but it is known to be quite slow. Alternative hashes can be 10+ times faster (for example, there is a benchmark example in ahash)
What difficulties might arise?
It's unclear how to implement this
- Option 1. Keep the current implementation, but add a third argument with a default value, for example, the methods would look like this:
but the current Rust doesn’t know how to do this and writes something like
#[cfg(feature = "use_std")] fn into_group_map<K, V, R = RandomState>(self) -> HashMap<K, Vec<V>, R> where Self: Iterator<Item = (K, V)> + Sized, K: Hash + Eq, R: BuildHasher + Default { group_map::into_group_map(self) }
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions --> src/lib.rs:3076:29 | 3076 | fn into_group_map<K, V, R = RandomState>(self) -> HashMap<K, Vec<V>, R> | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> = note: `#[deny(invalid_type_param_default)]` on by default
- Option 2, we can try replacing all imports with a flag from std::collections::HashMap to ahash::HashMap, but this breaks backward compatibility
Maybe there are some other options?