@@ -19,11 +19,9 @@ use std::collections::{DList, RingBuf, BTreeMap, BTreeSet, HashMap, HashSet, Vec
19
19
use collections:: enum_set:: { EnumSet , CLike } ;
20
20
21
21
impl <
22
- E ,
23
- S : Encoder < E > ,
24
- T : Encodable < S , E >
25
- > Encodable < S , E > for DList < T > {
26
- fn encode ( & self , s : & mut S ) -> Result < ( ) , E > {
22
+ T : Encodable
23
+ > Encodable for DList < T > {
24
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
27
25
s. emit_seq ( self . len ( ) , |s| {
28
26
for ( i, e) in self . iter ( ) . enumerate ( ) {
29
27
try!( s. emit_seq_elt ( i, |s| e. encode ( s) ) ) ;
33
31
}
34
32
}
35
33
36
- impl < E , D : Decoder < E > , T : Decodable < D , E > > Decodable < D , E > for DList < T > {
37
- fn decode ( d : & mut D ) -> Result < DList < T > , E > {
34
+ impl < T : Decodable > Decodable for DList < T > {
35
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < DList < T > , D :: Error > {
38
36
d. read_seq ( |d, len| {
39
37
let mut list = DList :: new ( ) ;
40
38
for i in range ( 0 u, len) {
@@ -45,12 +43,8 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for DList<T> {
45
43
}
46
44
}
47
45
48
- impl <
49
- E ,
50
- S : Encoder < E > ,
51
- T : Encodable < S , E >
52
- > Encodable < S , E > for RingBuf < T > {
53
- fn encode ( & self , s : & mut S ) -> Result < ( ) , E > {
46
+ impl < T : Encodable > Encodable for RingBuf < T > {
47
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
54
48
s. emit_seq ( self . len ( ) , |s| {
55
49
for ( i, e) in self . iter ( ) . enumerate ( ) {
56
50
try!( s. emit_seq_elt ( i, |s| e. encode ( s) ) ) ;
60
54
}
61
55
}
62
56
63
- impl < E , D : Decoder < E > , T : Decodable < D , E > > Decodable < D , E > for RingBuf < T > {
64
- fn decode ( d : & mut D ) -> Result < RingBuf < T > , E > {
57
+ impl < T : Decodable > Decodable for RingBuf < T > {
58
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < RingBuf < T > , D :: Error > {
65
59
d. read_seq ( |d, len| {
66
60
let mut deque: RingBuf < T > = RingBuf :: new ( ) ;
67
61
for i in range ( 0 u, len) {
@@ -73,12 +67,10 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for RingBuf<T> {
73
67
}
74
68
75
69
impl <
76
- E ,
77
- S : Encoder < E > ,
78
- K : Encodable < S , E > + PartialEq + Ord ,
79
- V : Encodable < S , E > + PartialEq
80
- > Encodable < S , E > for BTreeMap < K , V > {
81
- fn encode ( & self , e : & mut S ) -> Result < ( ) , E > {
70
+ K : Encodable + PartialEq + Ord ,
71
+ V : Encodable + PartialEq
72
+ > Encodable for BTreeMap < K , V > {
73
+ fn encode < S : Encoder > ( & self , e : & mut S ) -> Result < ( ) , S :: Error > {
82
74
e. emit_map ( self . len ( ) , |e| {
83
75
let mut i = 0 ;
84
76
for ( key, val) in self . iter ( ) {
@@ -92,12 +84,10 @@ impl<
92
84
}
93
85
94
86
impl <
95
- E ,
96
- D : Decoder < E > ,
97
- K : Decodable < D , E > + PartialEq + Ord ,
98
- V : Decodable < D , E > + PartialEq
99
- > Decodable < D , E > for BTreeMap < K , V > {
100
- fn decode ( d : & mut D ) -> Result < BTreeMap < K , V > , E > {
87
+ K : Decodable + PartialEq + Ord ,
88
+ V : Decodable + PartialEq
89
+ > Decodable for BTreeMap < K , V > {
90
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < BTreeMap < K , V > , D :: Error > {
101
91
d. read_map ( |d, len| {
102
92
let mut map = BTreeMap :: new ( ) ;
103
93
for i in range ( 0 u, len) {
@@ -111,11 +101,9 @@ impl<
111
101
}
112
102
113
103
impl <
114
- E ,
115
- S : Encoder < E > ,
116
- T : Encodable < S , E > + PartialEq + Ord
117
- > Encodable < S , E > for BTreeSet < T > {
118
- fn encode ( & self , s : & mut S ) -> Result < ( ) , E > {
104
+ T : Encodable + PartialEq + Ord
105
+ > Encodable for BTreeSet < T > {
106
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
119
107
s. emit_seq ( self . len ( ) , |s| {
120
108
let mut i = 0 ;
121
109
for e in self . iter ( ) {
@@ -128,11 +116,9 @@ impl<
128
116
}
129
117
130
118
impl <
131
- E ,
132
- D : Decoder < E > ,
133
- T : Decodable < D , E > + PartialEq + Ord
134
- > Decodable < D , E > for BTreeSet < T > {
135
- fn decode ( d : & mut D ) -> Result < BTreeSet < T > , E > {
119
+ T : Decodable + PartialEq + Ord
120
+ > Decodable for BTreeSet < T > {
121
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < BTreeSet < T > , D :: Error > {
136
122
d. read_seq ( |d, len| {
137
123
let mut set = BTreeSet :: new ( ) ;
138
124
for i in range ( 0 u, len) {
@@ -144,11 +130,9 @@ impl<
144
130
}
145
131
146
132
impl <
147
- E ,
148
- S : Encoder < E > ,
149
- T : Encodable < S , E > + CLike
150
- > Encodable < S , E > for EnumSet < T > {
151
- fn encode ( & self , s : & mut S ) -> Result < ( ) , E > {
133
+ T : Encodable + CLike
134
+ > Encodable for EnumSet < T > {
135
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
152
136
let mut bits = 0 ;
153
137
for item in self . iter ( ) {
154
138
bits |= item. to_uint ( ) ;
@@ -158,11 +142,9 @@ impl<
158
142
}
159
143
160
144
impl <
161
- E ,
162
- D : Decoder < E > ,
163
- T : Decodable < D , E > + CLike
164
- > Decodable < D , E > for EnumSet < T > {
165
- fn decode ( d : & mut D ) -> Result < EnumSet < T > , E > {
145
+ T : Decodable + CLike
146
+ > Decodable for EnumSet < T > {
147
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < EnumSet < T > , D :: Error > {
166
148
let bits = try!( d. read_uint ( ) ) ;
167
149
let mut set = EnumSet :: new ( ) ;
168
150
for bit in range ( 0 , uint:: BITS ) {
@@ -175,14 +157,12 @@ impl<
175
157
}
176
158
177
159
impl <
178
- E ,
179
- S : Encoder < E > ,
180
- K : Encodable < S , E > + Hash < X > + Eq ,
181
- V : Encodable < S , E > ,
160
+ K : Encodable + Hash < X > + Eq ,
161
+ V : Encodable ,
182
162
X ,
183
163
H : Hasher < X >
184
- > Encodable < S , E > for HashMap < K , V , H > {
185
- fn encode ( & self , e : & mut S ) -> Result < ( ) , E > {
164
+ > Encodable for HashMap < K , V , H > {
165
+ fn encode < S : Encoder > ( & self , e : & mut S ) -> Result < ( ) , S :: Error > {
186
166
e. emit_map ( self . len ( ) , |e| {
187
167
let mut i = 0 ;
188
168
for ( key, val) in self . iter ( ) {
@@ -196,14 +176,12 @@ impl<
196
176
}
197
177
198
178
impl <
199
- E ,
200
- D : Decoder < E > ,
201
- K : Decodable < D , E > + Hash < S > + Eq ,
202
- V : Decodable < D , E > ,
179
+ K : Decodable + Hash < S > + Eq ,
180
+ V : Decodable ,
203
181
S ,
204
182
H : Hasher < S > + Default
205
- > Decodable < D , E > for HashMap < K , V , H > {
206
- fn decode ( d : & mut D ) -> Result < HashMap < K , V , H > , E > {
183
+ > Decodable for HashMap < K , V , H > {
184
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < HashMap < K , V , H > , D :: Error > {
207
185
d. read_map ( |d, len| {
208
186
let hasher = Default :: default ( ) ;
209
187
let mut map = HashMap :: with_capacity_and_hasher ( len, hasher) ;
@@ -218,13 +196,11 @@ impl<
218
196
}
219
197
220
198
impl <
221
- E ,
222
- S : Encoder < E > ,
223
- T : Encodable < S , E > + Hash < X > + Eq ,
199
+ T : Encodable + Hash < X > + Eq ,
224
200
X ,
225
201
H : Hasher < X >
226
- > Encodable < S , E > for HashSet < T , H > {
227
- fn encode ( & self , s : & mut S ) -> Result < ( ) , E > {
202
+ > Encodable for HashSet < T , H > {
203
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
228
204
s. emit_seq ( self . len ( ) , |s| {
229
205
let mut i = 0 ;
230
206
for e in self . iter ( ) {
@@ -237,13 +213,11 @@ impl<
237
213
}
238
214
239
215
impl <
240
- E ,
241
- D : Decoder < E > ,
242
- T : Decodable < D , E > + Hash < S > + Eq ,
216
+ T : Decodable + Hash < S > + Eq ,
243
217
S ,
244
218
H : Hasher < S > + Default
245
- > Decodable < D , E > for HashSet < T , H > {
246
- fn decode ( d : & mut D ) -> Result < HashSet < T , H > , E > {
219
+ > Decodable for HashSet < T , H > {
220
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < HashSet < T , H > , D :: Error > {
247
221
d. read_seq ( |d, len| {
248
222
let mut set = HashSet :: with_capacity_and_hasher ( len, Default :: default ( ) ) ;
249
223
for i in range ( 0 u, len) {
@@ -254,12 +228,8 @@ impl<
254
228
}
255
229
}
256
230
257
- impl <
258
- E ,
259
- S : Encoder < E > ,
260
- V : Encodable < S , E >
261
- > Encodable < S , E > for VecMap < V > {
262
- fn encode ( & self , e : & mut S ) -> Result < ( ) , E > {
231
+ impl < V : Encodable > Encodable for VecMap < V > {
232
+ fn encode < S : Encoder > ( & self , e : & mut S ) -> Result < ( ) , S :: Error > {
263
233
e. emit_map ( self . len ( ) , |e| {
264
234
for ( i, ( key, val) ) in self . iter ( ) . enumerate ( ) {
265
235
try!( e. emit_map_elt_key ( i, |e| key. encode ( e) ) ) ;
@@ -270,12 +240,8 @@ impl<
270
240
}
271
241
}
272
242
273
- impl <
274
- E ,
275
- D : Decoder < E > ,
276
- V : Decodable < D , E >
277
- > Decodable < D , E > for VecMap < V > {
278
- fn decode ( d : & mut D ) -> Result < VecMap < V > , E > {
243
+ impl < V : Decodable > Decodable for VecMap < V > {
244
+ fn decode < D : Decoder > ( d : & mut D ) -> Result < VecMap < V > , D :: Error > {
279
245
d. read_map ( |d, len| {
280
246
let mut map = VecMap :: new ( ) ;
281
247
for i in range ( 0 u, len) {
0 commit comments