10
10
11
11
//! Implementations of serialization for structures found in libcollections
12
12
13
- use std:: hash:: Hash ;
14
- use std:: collections:: hash_state:: HashState ;
13
+ use std:: hash:: { Hash , BuildHasher } ;
15
14
use std:: mem;
16
15
17
16
use { Decodable , Encodable , Decoder , Encoder } ;
@@ -159,7 +158,7 @@ impl<
159
158
impl < K , V , S > Encodable for HashMap < K , V , S >
160
159
where K : Encodable + Hash + Eq ,
161
160
V : Encodable ,
162
- S : HashState ,
161
+ S : BuildHasher ,
163
162
{
164
163
fn encode < E : Encoder > ( & self , e : & mut E ) -> Result < ( ) , E :: Error > {
165
164
e. emit_map ( self . len ( ) , |e| {
@@ -177,12 +176,12 @@ impl<K, V, S> Encodable for HashMap<K, V, S>
177
176
impl < K , V , S > Decodable for HashMap < K , V , S >
178
177
where K : Decodable + Hash + Eq ,
179
178
V : Decodable ,
180
- S : HashState + Default ,
179
+ S : BuildHasher + Default ,
181
180
{
182
181
fn decode < D : Decoder > ( d : & mut D ) -> Result < HashMap < K , V , S > , D :: Error > {
183
182
d. read_map ( |d, len| {
184
183
let state = Default :: default ( ) ;
185
- let mut map = HashMap :: with_capacity_and_hash_state ( len, state) ;
184
+ let mut map = HashMap :: with_capacity_and_hasher ( len, state) ;
186
185
for i in 0 ..len {
187
186
let key = try!( d. read_map_elt_key ( i, |d| Decodable :: decode ( d) ) ) ;
188
187
let val = try!( d. read_map_elt_val ( i, |d| Decodable :: decode ( d) ) ) ;
@@ -195,7 +194,7 @@ impl<K, V, S> Decodable for HashMap<K, V, S>
195
194
196
195
impl < T , S > Encodable for HashSet < T , S >
197
196
where T : Encodable + Hash + Eq ,
198
- S : HashState ,
197
+ S : BuildHasher ,
199
198
{
200
199
fn encode < E : Encoder > ( & self , s : & mut E ) -> Result < ( ) , E :: Error > {
201
200
s. emit_seq ( self . len ( ) , |s| {
@@ -211,12 +210,12 @@ impl<T, S> Encodable for HashSet<T, S>
211
210
212
211
impl < T , S > Decodable for HashSet < T , S >
213
212
where T : Decodable + Hash + Eq ,
214
- S : HashState + Default ,
213
+ S : BuildHasher + Default ,
215
214
{
216
215
fn decode < D : Decoder > ( d : & mut D ) -> Result < HashSet < T , S > , D :: Error > {
217
216
d. read_seq ( |d, len| {
218
217
let state = Default :: default ( ) ;
219
- let mut set = HashSet :: with_capacity_and_hash_state ( len, state) ;
218
+ let mut set = HashSet :: with_capacity_and_hasher ( len, state) ;
220
219
for i in 0 ..len {
221
220
set. insert ( try!( d. read_seq_elt ( i, |d| Decodable :: decode ( d) ) ) ) ;
222
221
}
0 commit comments