@@ -201,15 +201,6 @@ pub trait Decoder {
201201 fn read_str ( & mut self ) -> Cow < ' _ , str > ;
202202 fn read_raw_bytes_into ( & mut self , s : & mut [ u8 ] ) ;
203203
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-
213204 fn read_seq < T , F > ( & mut self , f : F ) -> T
214205 where
215206 F : FnOnce ( & mut Self , usize ) -> T ,
@@ -473,11 +464,11 @@ impl<S: Encoder, T: Encodable<S>> Encodable<S> for Option<T> {
473464
474465impl < D : Decoder , T : Decodable < D > > Decodable < D > for Option < T > {
475466 fn decode ( d : & mut D ) -> Option < T > {
476- d . read_enum_variant ( move |this , idx| match idx {
467+ match d . read_usize ( ) {
477468 0 => None ,
478- 1 => Some ( Decodable :: decode ( this ) ) ,
469+ 1 => Some ( Decodable :: decode ( d ) ) ,
479470 _ => panic ! ( "Encountered invalid discriminant while decoding `Option`." ) ,
480- } )
471+ }
481472 }
482473}
483474
@@ -496,11 +487,11 @@ impl<S: Encoder, T1: Encodable<S>, T2: Encodable<S>> Encodable<S> for Result<T1,
496487
497488impl < D : Decoder , T1 : Decodable < D > , T2 : Decodable < D > > Decodable < D > for Result < T1 , T2 > {
498489 fn decode ( d : & mut D ) -> Result < T1 , T2 > {
499- d . read_enum_variant ( |d , disr| match disr {
490+ match d . read_usize ( ) {
500491 0 => Ok ( T1 :: decode ( d) ) ,
501492 1 => Err ( T2 :: decode ( d) ) ,
502493 _ => panic ! ( "Encountered invalid discriminant while decoding `Result`." ) ,
503- } )
494+ }
504495 }
505496}
506497
0 commit comments