File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
compiler/rustc_serialize/src Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -210,18 +210,6 @@ pub trait Decoder {
210
210
f ( self , disr)
211
211
}
212
212
213
- // Specialized types:
214
- fn read_option < T , F > ( & mut self , mut f : F ) -> T
215
- where
216
- F : FnMut ( & mut Self , bool ) -> T ,
217
- {
218
- self . read_enum_variant ( move |this, idx| match idx {
219
- 0 => f ( this, false ) ,
220
- 1 => f ( this, true ) ,
221
- _ => panic ! ( "read_option: expected 0 for None or 1 for Some" ) ,
222
- } )
223
- }
224
-
225
213
fn read_seq < T , F > ( & mut self , f : F ) -> T
226
214
where
227
215
F : FnOnce ( & mut Self , usize ) -> T ,
@@ -501,7 +489,11 @@ impl<S: Encoder, T: Encodable<S>> Encodable<S> for Option<T> {
501
489
502
490
impl < D : Decoder , T : Decodable < D > > Decodable < D > for Option < T > {
503
491
fn decode ( d : & mut D ) -> Option < T > {
504
- d. read_option ( |d, b| if b { Some ( Decodable :: decode ( d) ) } else { None } )
492
+ d. read_enum_variant ( move |this, idx| match idx {
493
+ 0 => None ,
494
+ 1 => Some ( Decodable :: decode ( this) ) ,
495
+ _ => panic ! ( "Encountered invalid discriminant while decoding `Option`." ) ,
496
+ } )
505
497
}
506
498
}
507
499
You can’t perform that action at this time.
0 commit comments