std: Stabilize the hash module
This commit is an implementation of [RFC 823][rfc] which is another pass over the `std::hash` module for stabilization. The contents of the module were not entirely marked stable, but some portions which remained quite similar to the previous incarnation are now marked `#[stable]`. Specifically: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0823-hash-simplification.md * `std::hash` is now stable (the name) * `Hash` is now stable * `Hash::hash` is now stable * `Hasher` is now stable * `SipHasher` is now stable * `SipHasher::new` and `new_with_keys` are now stable * `Hasher for SipHasher` is now stable * Many `Hash` implementations are now stable All other portions of the `hash` module remain `#[unstable]` as they are less commonly used and were recently redesigned. This commit is a breaking change due to the modifications to the `std::hash` API and more details can be found on the [RFC][rfc]. Closes #22467 [breaking-change]
This commit is contained in:
parent
dfc5c0f1e8
commit
f83e23ad7c
54 changed files with 5004 additions and 372 deletions
|
|
@ -18,7 +18,6 @@ extern crate rand;
|
|||
use std::collections::BTreeSet;
|
||||
use std::collections::BitvSet;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::hash_map::Hasher;
|
||||
use std::hash::Hash;
|
||||
use std::env;
|
||||
use std::time::Duration;
|
||||
|
|
@ -43,7 +42,7 @@ trait MutableSet<T> {
|
|||
fn contains(&self, k: &T) -> bool;
|
||||
}
|
||||
|
||||
impl<T: Hash<Hasher> + Eq> MutableSet<T> for HashSet<T> {
|
||||
impl<T: Hash + Eq> MutableSet<T> for HashSet<T> {
|
||||
fn insert(&mut self, k: T) { self.insert(k); }
|
||||
fn remove(&mut self, k: &T) -> bool { self.remove(k) }
|
||||
fn contains(&self, k: &T) -> bool { self.contains(k) }
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ impl Bar {
|
|||
|
||||
#[derive(Hash)]
|
||||
struct Foo(Bar);
|
||||
//~^ error: the trait `core::hash::Hash<_>` is not implemented for the type `Bar`
|
||||
//~^ error: the trait `core::hash::Hash` is not implemented for the type `Bar`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct Person {
|
|||
phone: uint,
|
||||
}
|
||||
|
||||
fn hash<T: Hash<SipHasher>>(t: &T) -> u64 {
|
||||
fn hash<T: Hash>(t: &T) -> u64 {
|
||||
std::hash::hash::<T, SipHasher>(t)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct Foo {
|
|||
baz: int
|
||||
}
|
||||
|
||||
fn hash<T: Hash<SipHasher>>(_t: &T) {}
|
||||
fn hash<T: Hash>(_t: &T) {}
|
||||
|
||||
pub fn main() {
|
||||
let a = Foo {bar: 4, baz: -3};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct Foo {
|
|||
baz: int
|
||||
}
|
||||
|
||||
fn hash<T: Hash<SipHasher>>(_t: &T) {}
|
||||
fn hash<T: Hash>(_t: &T) {}
|
||||
|
||||
pub fn main() {
|
||||
let a = Foo {bar: 4, baz: -3};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue