diff --git a/serde/src/private/ser.rs b/serde/src/private/ser.rs index 5b277852..043bfb63 100644 --- a/serde/src/private/ser.rs +++ b/serde/src/private/ser.rs @@ -1032,12 +1032,12 @@ mod content { } #[cfg(any(feature = "std", feature = "alloc"))] -pub struct FlatMapSerializer(M); +pub struct FlatMapSerializer<'a, M: 'a>(pub &'a mut M); #[cfg(any(feature = "std", feature = "alloc"))] -impl FlatMapSerializer +impl<'a, M> FlatMapSerializer<'a, M> where - M: SerializeMap + M: SerializeMap + 'a { fn bad_type(self, what: Unsupported) -> M::Error { ser::Error::custom(format_args!( @@ -1047,8 +1047,8 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl Serializer for FlatMapSerializer - where M: SerializeMap +impl<'a, M> Serializer for FlatMapSerializer<'a, M> + where M: SerializeMap + 'a { type Ok = M::Ok; type Error = M::Error; @@ -1056,8 +1056,8 @@ impl Serializer for FlatMapSerializer type SerializeSeq = Impossible; type SerializeTuple = Impossible; type SerializeTupleStruct = Impossible; - type SerializeMap = FlatMapSerializeMap; - type SerializeStruct = FlatMapSerializeStruct; + type SerializeMap = FlatMapSerializeMap<'a, M>; + type SerializeStruct = FlatMapSerializeStruct<'a, M>; type SerializeTupleVariant = Impossible; type SerializeStructVariant = Impossible; @@ -1220,11 +1220,11 @@ impl Serializer for FlatMapSerializer } #[cfg(any(feature = "std", feature = "alloc"))] -pub struct FlatMapSerializeMap(M); +pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M); #[cfg(any(feature = "std", feature = "alloc"))] -impl ser::SerializeMap for FlatMapSerializeMap - where M: SerializeMap +impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M> + where M: SerializeMap + 'a { type Ok = M::Ok; type Error = M::Error; @@ -1249,11 +1249,11 @@ impl ser::SerializeMap for FlatMapSerializeMap } #[cfg(any(feature = "std", feature = "alloc"))] -pub struct FlatMapSerializeStruct(M); +pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M); #[cfg(any(feature = "std", feature = "alloc"))] -impl ser::SerializeStruct for FlatMapSerializeStruct - where M: SerializeMap +impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M> + where M: SerializeMap + 'a { type Ok = M::Ok; type Error = M::Error;