From 75d5f27f8ac4c900c9565f3bafe28080df49f9ff Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sat, 17 Jan 2015 20:56:06 -0800 Subject: [PATCH] wip --- serde2/src/de.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/serde2/src/de.rs b/serde2/src/de.rs index 82994079..9a0316df 100644 --- a/serde2/src/de.rs +++ b/serde2/src/de.rs @@ -1,5 +1,6 @@ +use std::collections::hash_map::Hasher; use std::collections::{HashMap, BTreeMap}; -use std::hash::{Hash, Hasher}; +use std::hash::Hash; use std::num::FromPrimitive; use std::str; @@ -594,19 +595,18 @@ tuple_impls! { /////////////////////////////////////////////////////////////////////////////// -struct HashMapVisitor; +struct HashMapVisitor; -impl Visitor for HashMapVisitor - where K: Deserialize + Eq + Hash, +impl Visitor for HashMapVisitor + where K: Deserialize + Eq + Hash, V: Deserialize, - H: Hasher, { type Value = HashMap; #[inline] fn visit_map< - Visitor: MapVisitor, - >(&mut self, mut visitor: Visitor) -> Result, Visitor::Error> { + V_: MapVisitor, + >(&mut self, mut visitor: V_) -> Result, V_::Error> { let (len, _) = visitor.size_hint(); let mut values = HashMap::with_capacity(len); @@ -618,17 +618,19 @@ impl Visitor for HashMapVisitor } } -impl< - K: Deserialize + Eq + Hash, - V: Deserialize, -> Deserialize for HashMap { +impl Deserialize for HashMap + where K: Deserialize + Eq + Hash, + V: Deserialize, +{ fn deserialize< - S: Deserializer, - >(state: &mut S) -> Result, S::Error> { + S_: Deserializer, + >(state: &mut S_) -> Result, S_::Error> { state.visit(&mut HashMapVisitor) } } +/////////////////////////////////////////////////////////////////////////////// + struct BTreeMapVisitor; impl Visitor for BTreeMapVisitor