diff --git a/serde2/src/de.rs b/serde2/src/de.rs index 0cd139c8..4434f5c3 100644 --- a/serde2/src/de.rs +++ b/serde2/src/de.rs @@ -1,4 +1,4 @@ -use std::collections::hash_map::Hasher; +use std::marker::PhantomData; use std::collections::{HashMap, BTreeMap}; use std::hash::Hash; use std::num::FromPrimitive; @@ -357,7 +357,9 @@ macro_rules! impl_deserialize_num_method { } } -pub struct PrimitiveVisitor; +pub struct PrimitiveVisitor { + marker: PhantomData, +} impl< T: Deserialize + FromPrimitive @@ -385,7 +387,7 @@ macro_rules! impl_deserialize_num { fn deserialize< D: Deserializer, >(deserializer: &mut D) -> Result<$ty, D::Error> { - deserializer.visit(&mut PrimitiveVisitor) + deserializer.visit(&mut PrimitiveVisitor { marker: PhantomData }) } } } @@ -474,7 +476,9 @@ impl Deserialize for String { /////////////////////////////////////////////////////////////////////////////// -struct OptionVisitor; +struct OptionVisitor { + marker: PhantomData, +} impl< T: Deserialize, @@ -500,13 +504,15 @@ impl Deserialize for Option where T: Deserialize { fn deserialize< D: Deserializer, >(deserializer: &mut D) -> Result, D::Error> { - deserializer.visit_option(&mut OptionVisitor) + deserializer.visit_option(&mut OptionVisitor { marker: PhantomData }) } } /////////////////////////////////////////////////////////////////////////////// -struct VecVisitor; +struct VecVisitor { + marker: PhantomData, +} impl Visitor for VecVisitor where T: Deserialize { type Value = Vec; @@ -529,7 +535,7 @@ impl Deserialize for Vec { fn deserialize< D: Deserializer, >(deserializer: &mut D) -> Result, D::Error> { - deserializer.visit(&mut VecVisitor) + deserializer.visit(&mut VecVisitor { marker: PhantomData }) } } @@ -539,7 +545,9 @@ macro_rules! tuple_impls { () => {}; ($($visitor:ident => ($($name:ident),+),)+) => { $( - struct $visitor<$($name,)+>; + struct $visitor<$($name,)+> { + marker: PhantomData<($($name,)+)>, + } impl< $($name: Deserialize,)+ @@ -571,7 +579,7 @@ macro_rules! tuple_impls { fn deserialize< D: Deserializer, >(deserializer: &mut D) -> Result<($($name,)+), D::Error> { - deserializer.visit(&mut $visitor) + deserializer.visit(&mut $visitor { marker: PhantomData }) } } )+ @@ -595,10 +603,12 @@ tuple_impls! { /////////////////////////////////////////////////////////////////////////////// -struct HashMapVisitor; +struct HashMapVisitor { + marker: PhantomData>, +} impl Visitor for HashMapVisitor - where K: Deserialize + Eq + Hash, + where K: Deserialize + Eq + Hash, V: Deserialize, { type Value = HashMap; @@ -619,19 +629,21 @@ impl Visitor for HashMapVisitor } impl Deserialize for HashMap - where K: Deserialize + Eq + Hash, + where K: Deserialize + Eq + Hash, V: Deserialize, { fn deserialize< D: Deserializer, >(deserializer: &mut D) -> Result, D::Error> { - deserializer.visit(&mut HashMapVisitor) + deserializer.visit(&mut HashMapVisitor { marker: PhantomData }) } } /////////////////////////////////////////////////////////////////////////////// -struct BTreeMapVisitor; +struct BTreeMapVisitor { + marker: PhantomData>, +} impl Visitor for BTreeMapVisitor where K: Deserialize + Ord, @@ -660,7 +672,7 @@ impl< fn deserialize< D: Deserializer, >(deserializer: &mut D) -> Result, D::Error> { - deserializer.visit(&mut BTreeMapVisitor) + deserializer.visit(&mut BTreeMapVisitor { marker: PhantomData }) } } diff --git a/serde2/src/lib.rs b/serde2/src/lib.rs index 0fd403e3..85fd10c5 100644 --- a/serde2/src/lib.rs +++ b/serde2/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(core, hash, io, std_misc, unicode)] +#![feature(core, io, std_misc, unicode)] extern crate unicode; diff --git a/serde2/src/ser.rs b/serde2/src/ser.rs index 3d198909..eab17afc 100644 --- a/serde2/src/ser.rs +++ b/serde2/src/ser.rs @@ -1,6 +1,6 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::collections::hash_state::HashState; -use std::hash::{Hash, Hasher}; +use std::hash::Hash; use std::rc::Rc; use std::str; use std::sync::Arc; @@ -333,10 +333,9 @@ impl Serialize for BTreeSet where T: Serialize { } } -impl Serialize for HashSet - where T: Serialize + Eq + Hash, - S: HashState, - H: Hasher, +impl Serialize for HashSet + where T: Serialize + Eq + Hash, + S: HashState, { #[inline] fn visit(&self, visitor: &mut V) -> Result { @@ -586,11 +585,10 @@ impl Serialize for BTreeMap } } -impl Serialize for HashMap - where K: Serialize + Eq + Hash, +impl Serialize for HashMap + where K: Serialize + Eq + Hash, V: Serialize, - S: HashState, - H: Hasher, + S: HashState, { #[inline] fn visit(&self, visitor: &mut V_) -> Result {