diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 1f1ad1711..bd4313c33 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -365,7 +365,26 @@ tuple_impls! { //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(feature = "std", feature = "alloc"))] +#[cfg(all(any(feature = "std", feature = "alloc"), not(no_relaxed_trait_bounds)))] +macro_rules! map_impl { + ($ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)* >) => { + impl Serialize for $ty + where + K: Serialize, + V: Serialize, + { + #[inline] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.collect_map(self) + } + } + } +} + +#[cfg(all(any(feature = "std", feature = "alloc"), no_relaxed_trait_bounds))] macro_rules! map_impl { ($ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)* >) => { impl Serialize for $ty