@@ -201,15 +201,6 @@ pub trait Decoder {
201
201
fn read_str ( & mut self ) -> Cow < ' _ , str > ;
202
202
fn read_raw_bytes_into ( & mut self , s : & mut [ u8 ] ) ;
203
203
204
- // Compound types:
205
- #[ inline]
206
- fn read_enum < T , F > ( & mut self , f : F ) -> T
207
- where
208
- F : FnOnce ( & mut Self ) -> T ,
209
- {
210
- f ( self )
211
- }
212
-
213
204
#[ inline]
214
205
fn read_enum_variant < T , F > ( & mut self , _names : & [ & str ] , mut f : F ) -> T
215
206
where
@@ -264,12 +255,10 @@ pub trait Decoder {
264
255
where
265
256
F : FnMut ( & mut Self , bool ) -> T ,
266
257
{
267
- self . read_enum ( move |this| {
268
- this. read_enum_variant ( & [ "None" , "Some" ] , move |this, idx| match idx {
269
- 0 => f ( this, false ) ,
270
- 1 => f ( this, true ) ,
271
- _ => panic ! ( "read_option: expected 0 for None or 1 for Some" ) ,
272
- } )
258
+ self . read_enum_variant ( & [ "None" , "Some" ] , move |this, idx| match idx {
259
+ 0 => f ( this, false ) ,
260
+ 1 => f ( this, true ) ,
261
+ _ => panic ! ( "read_option: expected 0 for None or 1 for Some" ) ,
273
262
} )
274
263
}
275
264
@@ -582,12 +571,10 @@ impl<S: Encoder, T1: Encodable<S>, T2: Encodable<S>> Encodable<S> for Result<T1,
582
571
583
572
impl < D : Decoder , T1 : Decodable < D > , T2 : Decodable < D > > Decodable < D > for Result < T1 , T2 > {
584
573
fn decode ( d : & mut D ) -> Result < T1 , T2 > {
585
- d. read_enum ( |d| {
586
- d. read_enum_variant ( & [ "Ok" , "Err" ] , |d, disr| match disr {
587
- 0 => Ok ( d. read_enum_variant_arg ( |d| T1 :: decode ( d) ) ) ,
588
- 1 => Err ( d. read_enum_variant_arg ( |d| T2 :: decode ( d) ) ) ,
589
- _ => panic ! ( "Encountered invalid discriminant while decoding `Result`." ) ,
590
- } )
574
+ d. read_enum_variant ( & [ "Ok" , "Err" ] , |d, disr| match disr {
575
+ 0 => Ok ( d. read_enum_variant_arg ( |d| T1 :: decode ( d) ) ) ,
576
+ 1 => Err ( d. read_enum_variant_arg ( |d| T2 :: decode ( d) ) ) ,
577
+ _ => panic ! ( "Encountered invalid discriminant while decoding `Result`." ) ,
591
578
} )
592
579
}
593
580
}
0 commit comments