From c3b792e79db45a0bd83c94f718171fce25786feb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 13 Aug 2022 14:52:37 -0700 Subject: [PATCH] Propagate collect_str in singleton_map Serializer --- src/with.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/with.rs b/src/with.rs index aa43f305..0585f1c0 100644 --- a/src/with.rs +++ b/src/with.rs @@ -81,7 +81,7 @@ pub mod singleton_map { use serde::ser::{ self, Serialize, SerializeMap, SerializeStructVariant, SerializeTupleVariant, Serializer, }; - use std::fmt; + use std::fmt::{self, Display}; #[allow(missing_docs)] pub fn serialize(value: &T, serializer: S) -> Result @@ -311,6 +311,13 @@ pub mod singleton_map { let mapping = Mapping::with_capacity(len); Ok(SerializeStructVariantAsSingletonMap { map, mapping }) } + + fn collect_str(self, value: &T) -> Result + where + T: ?Sized + Display, + { + self.delegate.collect_str(value) + } } struct SerializeTupleVariantAsSingletonMap {