Skip to content

Commit

Permalink
Generalize some serialization impls
Browse files Browse the repository at this point in the history
* Impl Serialize for bare `str`
* Expand `&T` and `&mut T` blanket impls to include `T: ?Sized`
* Expand `Box<T>` blanket impl to include `T: ?Sized`
  • Loading branch information
alexcrichton committed Apr 2, 2015
1 parent e150553 commit ace6d9e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ser/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ impl_visit!(char, visit_char);

///////////////////////////////////////////////////////////////////////////////

impl<'a> Serialize for &'a str {
impl Serialize for str {
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: Serializer,
{
serializer.visit_str(*self)
serializer.visit_str(self)
}
}

Expand Down Expand Up @@ -426,7 +426,7 @@ impl<V> Serialize for VecMap<V>

///////////////////////////////////////////////////////////////////////////////

impl<'a, T> Serialize for &'a T where T: Serialize {
impl<'a, T: ?Sized> Serialize for &'a T where T: Serialize {
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: Serializer,
Expand All @@ -435,7 +435,7 @@ impl<'a, T> Serialize for &'a T where T: Serialize {
}
}

impl<'a, T> Serialize for &'a mut T where T: Serialize {
impl<'a, T: ?Sized> Serialize for &'a mut T where T: Serialize {
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: Serializer,
Expand All @@ -444,7 +444,7 @@ impl<'a, T> Serialize for &'a mut T where T: Serialize {
}
}

impl<T> Serialize for Box<T> where T: Serialize {
impl<T: ?Sized> Serialize for Box<T> where T: Serialize {
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: Serializer,
Expand Down

0 comments on commit ace6d9e

Please sign in to comment.