@@ -44,6 +44,20 @@ impl<'dt, I: Indexed> Deserialize<'dt> for Column<I> {
44
44
}
45
45
}
46
46
47
+ #[ cfg( feature = "serialize-rustc" ) ]
48
+ impl < I : Indexed > rustc_serialize:: Decodable for Column < I > {
49
+ fn decode < D : rustc_serialize:: Decoder > ( d : & mut D ) -> Result < Column < I > , D :: Error > {
50
+ d. read_u32 ( ) . map ( Column :: new)
51
+ }
52
+ }
53
+
54
+ #[ cfg( feature = "serialize-rustc" ) ]
55
+ impl < I : Indexed > rustc_serialize:: Encodable for Column < I > {
56
+ fn encode < S : rustc_serialize:: Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
57
+ s. emit_u32 ( self . 0 )
58
+ }
59
+ }
60
+
47
61
impl Column < OneIndexed > {
48
62
pub fn new_one_indexed ( c : u32 ) -> Column < OneIndexed > {
49
63
Column ( c, PhantomData )
@@ -93,6 +107,20 @@ impl<'dt, I: Indexed> serde::Deserialize<'dt> for Row<I> {
93
107
}
94
108
}
95
109
110
+ #[ cfg( feature = "serialize-rustc" ) ]
111
+ impl < I : Indexed > rustc_serialize:: Decodable for Row < I > {
112
+ fn decode < D : rustc_serialize:: Decoder > ( d : & mut D ) -> Result < Row < I > , D :: Error > {
113
+ d. read_u32 ( ) . map ( Row :: new)
114
+ }
115
+ }
116
+
117
+ #[ cfg( feature = "serialize-rustc" ) ]
118
+ impl < I : Indexed > rustc_serialize:: Encodable for Row < I > {
119
+ fn encode < S : rustc_serialize:: Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
120
+ s. emit_u32 ( self . 0 )
121
+ }
122
+ }
123
+
96
124
impl Row < OneIndexed > {
97
125
pub fn new_one_indexed ( c : u32 ) -> Row < OneIndexed > {
98
126
Row ( c, PhantomData )
@@ -114,6 +142,7 @@ impl Row<ZeroIndexed> {
114
142
}
115
143
116
144
#[ cfg_attr( feature = "derive" , derive( Serialize , Deserialize ) ) ]
145
+ #[ cfg_attr( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
117
146
#[ derive( Debug , Hash , PartialEq , Eq , PartialOrd , Ord ) ]
118
147
pub struct Position < I : Indexed > {
119
148
pub row : Row < I > ,
@@ -147,6 +176,7 @@ impl Position<ZeroIndexed> {
147
176
}
148
177
149
178
#[ cfg_attr( feature = "derive" , derive( Serialize , Deserialize ) ) ]
179
+ #[ cfg_attr( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
150
180
#[ derive( Debug , Hash , PartialEq , Eq , PartialOrd , Ord ) ]
151
181
pub struct Range < I : Indexed > {
152
182
pub row_start : Row < I > ,
@@ -209,6 +239,7 @@ impl Range<ZeroIndexed> {
209
239
}
210
240
211
241
#[ cfg_attr( feature = "derive" , derive( Serialize , Deserialize ) ) ]
242
+ #[ cfg_attr( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
212
243
#[ derive( Debug , Hash , PartialEq , Eq , PartialOrd , Ord ) ]
213
244
pub struct Location < I : Indexed > {
214
245
pub file : PathBuf ,
@@ -244,6 +275,7 @@ impl Location<ZeroIndexed> {
244
275
}
245
276
246
277
#[ cfg_attr( feature = "derive" , derive( Serialize , Deserialize ) ) ]
278
+ #[ cfg_attr( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
247
279
#[ derive( Debug , Hash , PartialEq , Eq , PartialOrd , Ord ) ]
248
280
pub struct Span < I : Indexed > {
249
281
pub file : PathBuf ,
@@ -295,11 +327,13 @@ impl Span<ZeroIndexed> {
295
327
pub trait Indexed { }
296
328
297
329
#[ cfg_attr( feature = "derive" , derive( Serialize , Deserialize ) ) ]
330
+ #[ cfg_attr( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
298
331
#[ derive( Hash , PartialEq , Eq , Debug , PartialOrd , Ord ) ]
299
332
pub struct ZeroIndexed ;
300
333
impl Indexed for ZeroIndexed { }
301
334
302
335
#[ cfg_attr( feature = "derive" , derive( Serialize , Deserialize ) ) ]
336
+ #[ cfg_attr( feature = "serialize-rustc" , derive( RustcDecodable , RustcEncodable ) ) ]
303
337
#[ derive( Hash , PartialEq , Eq , Debug , PartialOrd , Ord ) ]
304
338
pub struct OneIndexed ;
305
339
impl Indexed for OneIndexed { }
0 commit comments