parent
776e6448a2
commit
6b7aa269b8
@ -1,7 +1,8 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::collections::{HashMap, BTreeMap};
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::num::FromPrimitive;
|
||||
use std::path;
|
||||
use std::str;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -788,3 +789,31 @@ impl<
|
||||
deserializer.visit(BTreeMapVisitor::new())
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct PathBufVisitor;
|
||||
|
||||
impl Visitor for PathBufVisitor {
|
||||
type Value = path::PathBuf;
|
||||
|
||||
fn visit_str<E>(&mut self, v: &str) -> Result<path::PathBuf, E>
|
||||
where E: Error,
|
||||
{
|
||||
Ok(path::PathBuf::new(&v))
|
||||
}
|
||||
|
||||
fn visit_string<E>(&mut self, v: String) -> Result<path::PathBuf, E>
|
||||
where E: Error,
|
||||
{
|
||||
self.visit_str(&v)
|
||||
}
|
||||
}
|
||||
|
||||
impl Deserialize for path::PathBuf {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<path::PathBuf, D::Error>
|
||||
where D: Deserializer,
|
||||
{
|
||||
deserializer.visit(PathBufVisitor)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(core, io, std_misc, unicode)]
|
||||
#![feature(core, io, path, std_misc, unicode)]
|
||||
|
||||
extern crate unicode;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
use std::collections::hash_state::HashState;
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
use std::hash::Hash;
|
||||
use std::path;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use std::sync::Arc;
|
||||
@ -8,9 +9,8 @@ use std::sync::Arc;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait Serialize {
|
||||
fn visit<
|
||||
V: Visitor,
|
||||
>(&self, visitor: &mut V) -> Result<V::Value, V::Error>;
|
||||
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error>
|
||||
where V: Visitor;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -605,7 +605,7 @@ impl<'a, T> Serialize for &'a T where T: Serialize {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Serialize for Box<T> where T: Serialize {
|
||||
impl<T> Serialize for Box<T> where T: Serialize {
|
||||
#[inline]
|
||||
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error>
|
||||
where V: Visitor,
|
||||
@ -614,9 +614,7 @@ impl<'a, T> Serialize for Box<T> where T: Serialize {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Serialize for Rc<T>
|
||||
where T: Serialize,
|
||||
{
|
||||
impl<T> Serialize for Rc<T> where T: Serialize, {
|
||||
#[inline]
|
||||
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error>
|
||||
where V: Visitor,
|
||||
@ -625,9 +623,7 @@ impl<'a, T> Serialize for Rc<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Serialize for Arc<T>
|
||||
where T: Serialize,
|
||||
{
|
||||
impl<T> Serialize for Arc<T> where T: Serialize, {
|
||||
#[inline]
|
||||
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error>
|
||||
where V: Visitor,
|
||||
@ -635,3 +631,21 @@ impl<'a, T> Serialize for Arc<T>
|
||||
(**self).visit(visitor)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
impl Serialize for path::Path {
|
||||
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.to_str().unwrap().visit(visitor)
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for path::PathBuf {
|
||||
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.to_str().unwrap().visit(visitor)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user