From c6bd6b444ca7718eca5bbd86a4438e779f31dc5e Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 9 Feb 2022 17:10:45 -0500 Subject: Delete Decoder::read_enum --- compiler/rustc_serialize/src/serialize.rs | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'compiler/rustc_serialize') diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index a6172403fd6..6e0199260f8 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -201,15 +201,6 @@ pub trait Decoder { fn read_str(&mut self) -> Cow<'_, str>; fn read_raw_bytes_into(&mut self, s: &mut [u8]); - // Compound types: - #[inline] - fn read_enum(&mut self, f: F) -> T - where - F: FnOnce(&mut Self) -> T, - { - f(self) - } - #[inline] fn read_enum_variant(&mut self, _names: &[&str], mut f: F) -> T where @@ -264,12 +255,10 @@ pub trait Decoder { where F: FnMut(&mut Self, bool) -> T, { - self.read_enum(move |this| { - this.read_enum_variant(&["None", "Some"], move |this, idx| match idx { - 0 => f(this, false), - 1 => f(this, true), - _ => panic!("read_option: expected 0 for None or 1 for Some"), - }) + self.read_enum_variant(&["None", "Some"], move |this, idx| match idx { + 0 => f(this, false), + 1 => f(this, true), + _ => panic!("read_option: expected 0 for None or 1 for Some"), }) } @@ -582,12 +571,10 @@ impl, T2: Encodable> Encodable for Result, T2: Decodable> Decodable for Result { fn decode(d: &mut D) -> Result { - d.read_enum(|d| { - d.read_enum_variant(&["Ok", "Err"], |d, disr| match disr { - 0 => Ok(d.read_enum_variant_arg(|d| T1::decode(d))), - 1 => Err(d.read_enum_variant_arg(|d| T2::decode(d))), - _ => panic!("Encountered invalid discriminant while decoding `Result`."), - }) + d.read_enum_variant(&["Ok", "Err"], |d, disr| match disr { + 0 => Ok(d.read_enum_variant_arg(|d| T1::decode(d))), + 1 => Err(d.read_enum_variant_arg(|d| T2::decode(d))), + _ => panic!("Encountered invalid discriminant while decoding `Result`."), }) } } -- cgit 1.4.1-3-g733a5