diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index 0c2f3b82..c58fc587 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -1741,6 +1741,25 @@ mod content { _ => Err(self.invalid_type(&visitor)), } } + + fn deserialize_float(self, visitor: V) -> Result + where + V: Visitor<'de>, + { + match *self.content { + Content::F32(v) => visitor.visit_f32(v), + Content::F64(v) => visitor.visit_f64(v), + Content::U8(v) => visitor.visit_u8(v), + Content::U16(v) => visitor.visit_u16(v), + Content::U32(v) => visitor.visit_u32(v), + Content::U64(v) => visitor.visit_u64(v), + Content::I8(v) => visitor.visit_i8(v), + Content::I16(v) => visitor.visit_i16(v), + Content::I32(v) => visitor.visit_i32(v), + Content::I64(v) => visitor.visit_i64(v), + _ => Err(self.invalid_type(&visitor)), + } + } } fn visit_content_seq_ref<'a, 'de, V, E>( @@ -1888,25 +1907,14 @@ mod content { where V: Visitor<'de>, { - match *self.content { - Content::F32(v) => visitor.visit_f32(v), - Content::F64(v) => visitor.visit_f64(v), - Content::U64(v) => visitor.visit_u64(v), - Content::I64(v) => visitor.visit_i64(v), - _ => Err(self.invalid_type(&visitor)), - } + self.deserialize_float(visitor) } fn deserialize_f64(self, visitor: V) -> Result where V: Visitor<'de>, { - match *self.content { - Content::F64(v) => visitor.visit_f64(v), - Content::U64(v) => visitor.visit_u64(v), - Content::I64(v) => visitor.visit_i64(v), - _ => Err(self.invalid_type(&visitor)), - } + self.deserialize_float(visitor) } fn deserialize_char(self, visitor: V) -> Result