From 112dfd7428601ee75e203c177b1adb0b29c52d57 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 15 Mar 2018 22:21:11 +0100 Subject: [PATCH] Correctly suppress the end() call for flattened serialization --- serde/src/private/ser.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/serde/src/private/ser.rs b/serde/src/private/ser.rs index 043bfb63..f19c4063 100644 --- a/serde/src/private/ser.rs +++ b/serde/src/private/ser.rs @@ -1050,16 +1050,16 @@ where impl<'a, M> Serializer for FlatMapSerializer<'a, M> where M: SerializeMap + 'a { - type Ok = M::Ok; + type Ok = (); type Error = M::Error; - type SerializeSeq = Impossible; - type SerializeTuple = Impossible; - type SerializeTupleStruct = Impossible; + type SerializeSeq = Impossible; + type SerializeTuple = Impossible; + type SerializeTupleStruct = Impossible; type SerializeMap = FlatMapSerializeMap<'a, M>; type SerializeStruct = FlatMapSerializeStruct<'a, M>; - type SerializeTupleVariant = Impossible; - type SerializeStructVariant = Impossible; + type SerializeTupleVariant = Impossible; + type SerializeStructVariant = Impossible; fn serialize_bool(self, _: bool) -> Result { Err(self.bad_type(Unsupported::Boolean)) @@ -1226,7 +1226,7 @@ pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M); impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M> where M: SerializeMap + 'a { - type Ok = M::Ok; + type Ok = (); type Error = M::Error; fn serialize_key(&mut self, key: &T) -> Result<(), Self::Error> @@ -1243,8 +1243,8 @@ impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M> self.0.serialize_value(value) } - fn end(self) -> Result { - self.0.end() + fn end(self) -> Result<(), Self::Error> { + Ok(()) } } @@ -1255,7 +1255,7 @@ pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M); impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M> where M: SerializeMap + 'a { - type Ok = M::Ok; + type Ok = (); type Error = M::Error; fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> @@ -1265,7 +1265,7 @@ impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M> self.0.serialize_entry(key, value) } - fn end(self) -> Result { - self.0.end() + fn end(self) -> Result<(), Self::Error> { + Ok(()) } }