@@ -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
- #[ inline]
205
- fn read_enum_variant < T , F > ( & mut self , mut f : F ) -> T
206
- where
207
- F : FnMut ( & mut Self , usize ) -> T ,
208
- {
209
- let disr = self . read_usize ( ) ;
210
- f ( self , disr)
211
- }
212
-
213
204
fn read_seq < T , F > ( & mut self , f : F ) -> T
214
205
where
215
206
F : FnOnce ( & mut Self , usize ) -> T ,
@@ -473,11 +464,11 @@ impl<S: Encoder, T: Encodable<S>> Encodable<S> for Option<T> {
473
464
474
465
impl < D : Decoder , T : Decodable < D > > Decodable < D > for Option < T > {
475
466
fn decode ( d : & mut D ) -> Option < T > {
476
- d . read_enum_variant ( move |this , idx| match idx {
467
+ match d . read_usize ( ) {
477
468
0 => None ,
478
- 1 => Some ( Decodable :: decode ( this ) ) ,
469
+ 1 => Some ( Decodable :: decode ( d ) ) ,
479
470
_ => panic ! ( "Encountered invalid discriminant while decoding `Option`." ) ,
480
- } )
471
+ }
481
472
}
482
473
}
483
474
@@ -496,11 +487,11 @@ impl<S: Encoder, T1: Encodable<S>, T2: Encodable<S>> Encodable<S> for Result<T1,
496
487
497
488
impl < D : Decoder , T1 : Decodable < D > , T2 : Decodable < D > > Decodable < D > for Result < T1 , T2 > {
498
489
fn decode ( d : & mut D ) -> Result < T1 , T2 > {
499
- d . read_enum_variant ( |d , disr| match disr {
490
+ match d . read_usize ( ) {
500
491
0 => Ok ( T1 :: decode ( d) ) ,
501
492
1 => Err ( T2 :: decode ( d) ) ,
502
493
_ => panic ! ( "Encountered invalid discriminant while decoding `Result`." ) ,
503
- } )
494
+ }
504
495
}
505
496
}
506
497
0 commit comments