Generalize some serialization impls
* 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`
This commit is contained in:
parent
e150553d58
commit
ace6d9e442
@ -44,12 +44,12 @@ impl_visit!(char, visit_char);
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
impl<'a> Serialize for &'a str {
|
impl Serialize for str {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: Serializer,
|
where S: Serializer,
|
||||||
{
|
{
|
||||||
serializer.visit_str(*self)
|
serializer.visit_str(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: Serializer,
|
where S: Serializer,
|
||||||
@ -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]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: Serializer,
|
where S: Serializer,
|
||||||
@ -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]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: Serializer,
|
where S: Serializer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user