Merge pull request #49 from alexcrichton/tweak-some-impls
Tweak some Deserialize/Serialize impls
This commit is contained in:
commit
87503d11e9
@ -3,6 +3,8 @@ use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::num::FromPrimitive;
|
||||
use std::path;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use de::{
|
||||
Deserialize,
|
||||
@ -650,3 +652,31 @@ impl Deserialize for path::PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
impl<T: Deserialize> Deserialize for Box<T> {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<Box<T>, D::Error>
|
||||
where D: Deserializer,
|
||||
{
|
||||
let val = try!(Deserialize::deserialize(deserializer));
|
||||
Ok(Box::new(val))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Deserialize> Deserialize for Arc<T> {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<Arc<T>, D::Error>
|
||||
where D: Deserializer,
|
||||
{
|
||||
let val = try!(Deserialize::deserialize(deserializer));
|
||||
Ok(Arc::new(val))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Deserialize> Deserialize for Rc<T> {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<Rc<T>, D::Error>
|
||||
where D: Deserializer,
|
||||
{
|
||||
let val = try!(Deserialize::deserialize(deserializer));
|
||||
Ok(Rc::new(val))
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user