File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -164,16 +164,31 @@ impl Eq for Span {}
164164
165165impl Encodable for Span {
166166 fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
167- try!( s. emit_u32 ( self . lo . 0 ) ) ;
168- s. emit_u32 ( self . hi . 0 )
167+ s. emit_struct ( "Span" , 2 , |s| {
168+ try!( s. emit_struct_field ( "lo" , 0 , |s| {
169+ self . lo . encode ( s)
170+ } ) ) ;
171+
172+ s. emit_struct_field ( "hi" , 1 , |s| {
173+ self . hi . encode ( s)
174+ } )
175+ } )
169176 }
170177}
171178
172179impl Decodable for Span {
173180 fn decode < D : Decoder > ( d : & mut D ) -> Result < Span , D :: Error > {
174- let lo = BytePos ( try! { d. read_u32 ( ) } ) ;
175- let hi = BytePos ( try! { d. read_u32 ( ) } ) ;
176- Ok ( mk_sp ( lo, hi) )
181+ d. read_struct ( "Span" , 2 , |d| {
182+ let lo = try!( d. read_struct_field ( "lo" , 0 , |d| {
183+ BytePos :: decode ( d)
184+ } ) ) ;
185+
186+ let hi = try!( d. read_struct_field ( "hi" , 1 , |d| {
187+ BytePos :: decode ( d)
188+ } ) ) ;
189+
190+ Ok ( mk_sp ( lo, hi) )
191+ } )
177192 }
178193}
179194
You can’t perform that action at this time.
0 commit comments