From 10476fd5743cb79f0ede4d53a3fce3ca90ea1acd Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 28 Jul 2016 11:28:12 -0700 Subject: [PATCH] Update to serde 0.8.0 --- Cargo.toml | 4 ++-- src/serde.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3fade5c..a558ef1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,5 +21,5 @@ serde_impl = ["serde", "serde_test"] [dependencies] clippy = { version = "0.*", optional = true } -serde = { version = "^0.7", optional = true } -serde_test = { version = "^0.7", optional = true } +serde = { version = "^0.8", optional = true } +serde_test = { version = "^0.8", optional = true } diff --git a/src/serde.rs b/src/serde.rs index ba55935..6ae6612 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -15,7 +15,6 @@ use std::hash::{BuildHasher, Hash}; use super::LinkedHashMap; use self::serde::{Serialize, Serializer, Deserialize, Deserializer}; -use self::serde::ser::impls::MapIteratorVisitor; use self::serde::de::{Visitor, MapVisitor, Error}; impl Serialize for LinkedHashMap @@ -27,7 +26,12 @@ impl Serialize for LinkedHashMap fn serialize(&self, serializer: &mut T) -> Result<(), T::Error> where T: Serializer, { - serializer.serialize_map(MapIteratorVisitor::new(self.iter(), Some(self.len()))) + let mut state = try!(serializer.serialize_map(Some(self.len()))); + for (k, v) in self { + try!(serializer.serialize_map_key(&mut state, k)); + try!(serializer.serialize_map_value(&mut state, v)); + } + serializer.serialize_map_end(state) } }