11
11
//! Implementations of serialization for structures found in libcollections
12
12
13
13
use std:: default:: Default ;
14
- use std:: hash:: { Hash , Hasher } ;
14
+ use std:: hash:: Hash ;
15
15
16
16
use { Decodable , Encodable , Decoder , Encoder } ;
17
- use std:: collections:: { DList , RingBuf , BTreeMap , BTreeSet , HashMap , HashSet , VecMap } ;
17
+ use std:: collections:: { LinkedList , VecDeque , BTreeMap , BTreeSet , HashMap , HashSet , VecMap } ;
18
18
use std:: collections:: hash_state:: HashState ;
19
19
20
20
impl <
21
21
T : Encodable
22
- > Encodable for DList < T > {
22
+ > Encodable for LinkedList < T > {
23
23
fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
24
24
s. emit_seq ( self . len ( ) , |s| {
25
25
for ( i, e) in self . iter ( ) . enumerate ( ) {
@@ -30,10 +30,10 @@ impl<
30
30
}
31
31
}
32
32
33
- impl < T : Decodable > Decodable for DList < T > {
34
- fn decode < D : Decoder > ( d : & mut D ) -> Result < DList < T > , D :: Error > {
33
+ impl < T : Decodable > Decodable for LinkedList < T > {
34
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < LinkedList < T > , D :: Error > {
35
35
d. read_seq ( |d, len| {
36
- let mut list = DList :: new ( ) ;
36
+ let mut list = LinkedList :: new ( ) ;
37
37
for i in 0 ..len {
38
38
list. push_back ( try!( d. read_seq_elt ( i, |d| Decodable :: decode ( d) ) ) ) ;
39
39
}
@@ -42,7 +42,7 @@ impl<T:Decodable> Decodable for DList<T> {
42
42
}
43
43
}
44
44
45
- impl < T : Encodable > Encodable for RingBuf < T > {
45
+ impl < T : Encodable > Encodable for VecDeque < T > {
46
46
fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
47
47
s. emit_seq ( self . len ( ) , |s| {
48
48
for ( i, e) in self . iter ( ) . enumerate ( ) {
@@ -53,10 +53,10 @@ impl<T: Encodable> Encodable for RingBuf<T> {
53
53
}
54
54
}
55
55
56
- impl < T : Decodable > Decodable for RingBuf < T > {
57
- fn decode < D : Decoder > ( d : & mut D ) -> Result < RingBuf < T > , D :: Error > {
56
+ impl < T : Decodable > Decodable for VecDeque < T > {
57
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < VecDeque < T > , D :: Error > {
58
58
d. read_seq ( |d, len| {
59
- let mut deque: RingBuf < T > = RingBuf :: new ( ) ;
59
+ let mut deque: VecDeque < T > = VecDeque :: new ( ) ;
60
60
for i in 0 ..len {
61
61
deque. push_back ( try!( d. read_seq_elt ( i, |d| Decodable :: decode ( d) ) ) ) ;
62
62
}
@@ -129,10 +129,9 @@ impl<
129
129
}
130
130
131
131
impl < K , V , S > Encodable for HashMap < K , V , S >
132
- where K : Encodable + Hash < < S as HashState > :: Hasher > + Eq ,
132
+ where K : Encodable + Hash + Eq ,
133
133
V : Encodable ,
134
134
S : HashState ,
135
- <S as HashState >:: Hasher : Hasher < Output =u64 >
136
135
{
137
136
fn encode < E : Encoder > ( & self , e : & mut E ) -> Result < ( ) , E :: Error > {
138
137
e. emit_map ( self . len ( ) , |e| {
@@ -148,10 +147,9 @@ impl<K, V, S> Encodable for HashMap<K, V, S>
148
147
}
149
148
150
149
impl < K , V , S > Decodable for HashMap < K , V , S >
151
- where K : Decodable + Hash < < S as HashState > :: Hasher > + Eq ,
150
+ where K : Decodable + Hash + Eq ,
152
151
V : Decodable ,
153
152
S : HashState + Default ,
154
- <S as HashState >:: Hasher : Hasher < Output =u64 >
155
153
{
156
154
fn decode < D : Decoder > ( d : & mut D ) -> Result < HashMap < K , V , S > , D :: Error > {
157
155
d. read_map ( |d, len| {
@@ -168,9 +166,8 @@ impl<K, V, S> Decodable for HashMap<K, V, S>
168
166
}
169
167
170
168
impl < T , S > Encodable for HashSet < T , S >
171
- where T : Encodable + Hash < < S as HashState > :: Hasher > + Eq ,
169
+ where T : Encodable + Hash + Eq ,
172
170
S : HashState ,
173
- <S as HashState >:: Hasher : Hasher < Output =u64 >
174
171
{
175
172
fn encode < E : Encoder > ( & self , s : & mut E ) -> Result < ( ) , E :: Error > {
176
173
s. emit_seq ( self . len ( ) , |s| {
@@ -185,9 +182,8 @@ impl<T, S> Encodable for HashSet<T, S>
185
182
}
186
183
187
184
impl < T , S > Decodable for HashSet < T , S >
188
- where T : Decodable + Hash < < S as HashState > :: Hasher > + Eq ,
185
+ where T : Decodable + Hash + Eq ,
189
186
S : HashState + Default ,
190
- <S as HashState >:: Hasher : Hasher < Output =u64 >
191
187
{
192
188
fn decode < D : Decoder > ( d : & mut D ) -> Result < HashSet < T , S > , D :: Error > {
193
189
d. read_seq ( |d, len| {
0 commit comments