-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No non-deprecated hasher in libcore #37071
Comments
EDIT: Nope, I'm an idiot, that's |
I tried implementing this and got: error[E0450]: cannot invoke tuple struct constructor with private fields
--> ../src/libstd/collections/hash/map.rs:2081:9
|
2081 | DefaultHasher(SipHasher13::new_with_keys(self.k0, self.k1))
| ^^^^^^^^^^^^^ cannot construct with a private field and I don’t see an easy way to fix this. But really, the problem here is that we want apparently want to deprecate the I find this inconsistent. Hashing is the foundation of hash maps, and we provide both for users of |
We can work around that in a hacky way by having a perma-unstable, doc(hidden) constructor. As far as public APIs go, we can add a constructor which takes a |
I would prefer to not have perma-unstable constructors where possible, including this. I also don't think |
To sum up, I see two issues:
|
I understand the desire to make the default hasher choice opaque, but obviously many applications depend upon access to a specific algorithm and |
It seems pretty reasonable to me to stick a SipHash implementation in a crate on crates.io. |
Agreeing with @SimonSapin and @burdges: When writing white/gray-box tests it's very nice to be able to fix a particular hashing function and keys. Less important but still nice is being able to put examples in docs and have them actually behave as promised even as Rust evolves. Rust is usually very good about helping me keep executions deterministic when I need them to be so, but having to refer to an external crate just to get a hasher whose meaning stays fixed over time is not so helpful. |
I would lean toward using a no_std hasher from crates.io. I don't believe it is important for core to contain at least one non-deprecated implementation of Hasher. |
Is there a |
https://crates.io/crates/siphasher is not in |
Since #36815, a
#![no_std]
crate that usescore::hash::SipHasher
gets a deprecation warning that says "useDefaultHasher
instead". ButDefaultHasher
is instd::collections::hash_map
and not available in libcore.All the Sip code is still in libcore, but there is no public non-deprecated API to use it or any other hasher.
Should
DefaultHasher
be moved tocore::hash
? (std::collections::hash_map
would have apub use
re-export.)CC @alexcrichton, @sfackler
The text was updated successfully, but these errors were encountered: