Skip to content

Commit

Permalink
Remove some Serialize trait bounds
Browse files Browse the repository at this point in the history
Containers for the most part do not have any trait requirements for
iterating over them. So these bounds are unnecessary when Serializing
only.
  • Loading branch information
jonasbb committed Dec 3, 2022
1 parent a6690ea commit cea3640
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions serde/src/ser/impls.rs
Expand Up @@ -184,11 +184,10 @@ where

#[cfg(any(feature = "std", feature = "alloc"))]
macro_rules! seq_impl {
($ty:ident < T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)* >) => {
($ty:ident < T $(, $typaram:ident)* >) => {
impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
where
T: Serialize $(+ $tbound1 $(+ $tbound2)*)*,
$($typaram: $bound,)*
T: Serialize,
{
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand All @@ -202,13 +201,13 @@ macro_rules! seq_impl {
}

#[cfg(any(feature = "std", feature = "alloc"))]
seq_impl!(BinaryHeap<T: Ord>);
seq_impl!(BinaryHeap<T>);

#[cfg(any(feature = "std", feature = "alloc"))]
seq_impl!(BTreeSet<T: Ord>);
seq_impl!(BTreeSet<T>);

#[cfg(feature = "std")]
seq_impl!(HashSet<T: Eq + Hash, H: BuildHasher>);
seq_impl!(HashSet<T, H>);

#[cfg(any(feature = "std", feature = "alloc"))]
seq_impl!(LinkedList<T>);
Expand Down

0 comments on commit cea3640

Please sign in to comment.