Remove the unused Serializer::Value associated type

This commit is contained in:
Erick Tryzelaar 2015-03-11 10:15:27 -07:00
parent 5d22be26d8
commit fbd6d1974a
8 changed files with 69 additions and 83 deletions

View File

@ -1,16 +1,13 @@
[package] [package]
name = "serde" name = "serde"
version = "0.2.1" version = "0.3.0"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
description = "A serialization/deserialization framework" description = "A serialization/deserialization framework"
repository = "https://github.com/erickt/rust-serde" repository = "https://github.com/erickt/rust-serde"
[lib]
name = "serde"
[dependencies] [dependencies]
rustc-serialize = "*" rustc-serialize = "*"
[dev-dependencies] [dev-dependencies.serde_macros]
serde_macros = "0.2.1" path = "serde_macros/"

View File

@ -58,7 +58,7 @@ impl ser::Serialize for HttpProtocol {
#[inline] #[inline]
fn visit< fn visit<
V: ser::Visitor, V: ser::Visitor,
>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { >(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_u8(*self as u8) visitor.visit_u8(*self as u8)
} }
} }
@ -106,7 +106,7 @@ impl ser::Serialize for HttpMethod {
#[inline] #[inline]
fn visit< fn visit<
V: ser::Visitor, V: ser::Visitor,
>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { >(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_u8(*self as u8) visitor.visit_u8(*self as u8)
} }
} }
@ -147,7 +147,7 @@ impl ser::Serialize for CacheStatus {
#[inline] #[inline]
fn visit< fn visit<
V: ser::Visitor, V: ser::Visitor,
>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { >(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_u8(*self as u8) visitor.visit_u8(*self as u8)
} }
} }
@ -197,7 +197,7 @@ impl ser::Serialize for OriginProtocol {
#[inline] #[inline]
fn visit< fn visit<
V: ser::Visitor, V: ser::Visitor,
>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { >(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_u8(*self as u8) visitor.visit_u8(*self as u8)
} }
} }
@ -239,7 +239,7 @@ impl ser::Serialize for ZonePlan {
#[inline] #[inline]
fn visit< fn visit<
V: ser::Visitor, V: ser::Visitor,
>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { >(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_u8(*self as u8) visitor.visit_u8(*self as u8)
} }
} }
@ -532,7 +532,7 @@ impl ser::Serialize for Country {
#[inline] #[inline]
fn visit< fn visit<
V: ser::Visitor, V: ser::Visitor,
>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { >(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_u8(*self as u8) visitor.visit_u8(*self as u8)
} }
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "serde_macros" name = "serde_macros"
version = "0.2.1" version = "0.3.0"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
description = "Macros to auto-generate implementations for the serde framework" description = "Macros to auto-generate implementations for the serde framework"

View File

@ -97,10 +97,7 @@ fn expand_derive_serialize(
vec!("std", "result", "Result"), vec!("std", "result", "Result"),
None, None,
vec![ vec![
Box::new(Ty::Literal(Path::new_(vec!["__V", "Value"], Box::new(Ty::Tuple(vec![])),
None,
vec![],
false))),
Box::new(Ty::Literal(Path::new_(vec!["__V", "Error"], Box::new(Ty::Literal(Path::new_(vec!["__V", "Error"],
None, None,
vec![], vec![],
@ -258,7 +255,7 @@ fn serialize_tuple_struct(
impl $visitor_impl_generics ::serde::ser::SeqVisitor for Visitor $visitor_generics { impl $visitor_impl_generics ::serde::ser::SeqVisitor for Visitor $visitor_generics {
#[inline] #[inline]
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: ::serde::ser::Visitor, where V: ::serde::ser::Visitor,
{ {
match self.state { match self.state {
@ -342,7 +339,7 @@ fn serialize_struct(
impl $visitor_impl_generics ::serde::ser::MapVisitor for Visitor $visitor_generics { impl $visitor_impl_generics ::serde::ser::MapVisitor for Visitor $visitor_generics {
#[inline] #[inline]
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: ::serde::ser::Visitor, where V: ::serde::ser::Visitor,
{ {
match self.state { match self.state {
@ -540,7 +537,7 @@ fn serialize_variant(
let methods = vec![ let methods = vec![
ast::MethodImplItem( ast::MethodImplItem(
quote_method!(cx, quote_method!(cx,
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: ::serde::ser::Visitor, where V: ::serde::ser::Visitor,
{ {
match self.state { match self.state {

View File

@ -52,7 +52,6 @@ impl<W: io::Write> Serializer<W> {
} }
impl<W: io::Write> ser::Serializer for Serializer<W> { impl<W: io::Write> ser::Serializer for Serializer<W> {
type Value = ();
type Error = io::Error; type Error = io::Error;
#[inline] #[inline]
@ -117,7 +116,6 @@ impl<'a, W> Visitor<'a, W> where W: io::Write, {
} }
impl<'a, W> ser::Visitor for Visitor<'a, W> where W: io::Write, { impl<'a, W> ser::Visitor for Visitor<'a, W> where W: io::Write, {
type Value = ();
type Error = io::Error; type Error = io::Error;
#[inline] #[inline]

View File

@ -21,7 +21,7 @@ pub enum Value {
impl ser::Serialize for Value { impl ser::Serialize for Value {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: ser::Visitor, where V: ser::Visitor,
{ {
match *self { match *self {
@ -163,7 +163,6 @@ impl Serializer {
} }
impl ser::Serializer for Serializer { impl ser::Serializer for Serializer {
type Value = ();
type Error = (); type Error = ();
#[inline] #[inline]
@ -176,7 +175,6 @@ impl ser::Serializer for Serializer {
} }
impl ser::Visitor for Serializer { impl ser::Visitor for Serializer {
type Value = ();
type Error = (); type Error = ();
#[inline] #[inline]

View File

@ -9,117 +9,115 @@ use std::sync::Arc;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
pub trait Serialize { pub trait Serialize {
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor; where V: Visitor;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
pub trait Serializer { pub trait Serializer {
type Value;
type Error; type Error;
fn visit<T>(&mut self, value: &T) -> Result<Self::Value, Self::Error> fn visit<T>(&mut self, value: &T) -> Result<(), Self::Error>
where T: Serialize; where T: Serialize;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
pub trait Visitor { pub trait Visitor {
type Value;
type Error; type Error;
fn visit_bool(&mut self, v: bool) -> Result<Self::Value, Self::Error>; fn visit_bool(&mut self, v: bool) -> Result<(), Self::Error>;
#[inline] #[inline]
fn visit_isize(&mut self, v: isize) -> Result<Self::Value, Self::Error> { fn visit_isize(&mut self, v: isize) -> Result<(), Self::Error> {
self.visit_i64(v as i64) self.visit_i64(v as i64)
} }
#[inline] #[inline]
fn visit_i8(&mut self, v: i8) -> Result<Self::Value, Self::Error> { fn visit_i8(&mut self, v: i8) -> Result<(), Self::Error> {
self.visit_i64(v as i64) self.visit_i64(v as i64)
} }
#[inline] #[inline]
fn visit_i16(&mut self, v: i16) -> Result<Self::Value, Self::Error> { fn visit_i16(&mut self, v: i16) -> Result<(), Self::Error> {
self.visit_i64(v as i64) self.visit_i64(v as i64)
} }
#[inline] #[inline]
fn visit_i32(&mut self, v: i32) -> Result<Self::Value, Self::Error> { fn visit_i32(&mut self, v: i32) -> Result<(), Self::Error> {
self.visit_i64(v as i64) self.visit_i64(v as i64)
} }
#[inline] #[inline]
fn visit_i64(&mut self, v: i64) -> Result<Self::Value, Self::Error>; fn visit_i64(&mut self, v: i64) -> Result<(), Self::Error>;
#[inline] #[inline]
fn visit_usize(&mut self, v: usize) -> Result<Self::Value, Self::Error> { fn visit_usize(&mut self, v: usize) -> Result<(), Self::Error> {
self.visit_u64(v as u64) self.visit_u64(v as u64)
} }
#[inline] #[inline]
fn visit_u8(&mut self, v: u8) -> Result<Self::Value, Self::Error> { fn visit_u8(&mut self, v: u8) -> Result<(), Self::Error> {
self.visit_u64(v as u64) self.visit_u64(v as u64)
} }
#[inline] #[inline]
fn visit_u16(&mut self, v: u16) -> Result<Self::Value, Self::Error> { fn visit_u16(&mut self, v: u16) -> Result<(), Self::Error> {
self.visit_u64(v as u64) self.visit_u64(v as u64)
} }
#[inline] #[inline]
fn visit_u32(&mut self, v: u32) -> Result<Self::Value, Self::Error> { fn visit_u32(&mut self, v: u32) -> Result<(), Self::Error> {
self.visit_u64(v as u64) self.visit_u64(v as u64)
} }
#[inline] #[inline]
fn visit_u64(&mut self, v: u64) -> Result<Self::Value, Self::Error>; fn visit_u64(&mut self, v: u64) -> Result<(), Self::Error>;
#[inline] #[inline]
fn visit_f32(&mut self, v: f32) -> Result<Self::Value, Self::Error> { fn visit_f32(&mut self, v: f32) -> Result<(), Self::Error> {
self.visit_f64(v as f64) self.visit_f64(v as f64)
} }
fn visit_f64(&mut self, v: f64) -> Result<Self::Value, Self::Error>; fn visit_f64(&mut self, v: f64) -> Result<(), Self::Error>;
#[inline] #[inline]
fn visit_char(&mut self, v: char) -> Result<Self::Value, Self::Error> { fn visit_char(&mut self, v: char) -> Result<(), Self::Error> {
// The unwraps in here should be safe. // The unwraps in here should be safe.
let mut s = &mut [0; 4]; let mut s = &mut [0; 4];
let len = v.encode_utf8(s).unwrap(); let len = v.encode_utf8(s).unwrap();
self.visit_str(str::from_utf8(&s[..len]).unwrap()) self.visit_str(str::from_utf8(&s[..len]).unwrap())
} }
fn visit_str(&mut self, value: &str) -> Result<Self::Value, Self::Error>; fn visit_str(&mut self, value: &str) -> Result<(), Self::Error>;
fn visit_unit(&mut self) -> Result<Self::Value, Self::Error>; fn visit_unit(&mut self) -> Result<(), Self::Error>;
#[inline] #[inline]
fn visit_named_unit(&mut self, _name: &str) -> Result<Self::Value, Self::Error> { fn visit_named_unit(&mut self, _name: &str) -> Result<(), Self::Error> {
self.visit_unit() self.visit_unit()
} }
#[inline] #[inline]
fn visit_enum_unit(&mut self, fn visit_enum_unit(&mut self,
_name: &str, _name: &str,
_variant: &str) -> Result<Self::Value, Self::Error> { _variant: &str) -> Result<(), Self::Error> {
self.visit_unit() self.visit_unit()
} }
fn visit_none(&mut self) -> Result<Self::Value, Self::Error>; fn visit_none(&mut self) -> Result<(), Self::Error>;
fn visit_some<V>(&mut self, value: V) -> Result<Self::Value, Self::Error> fn visit_some<V>(&mut self, value: V) -> Result<(), Self::Error>
where V: Serialize; where V: Serialize;
fn visit_seq<V>(&mut self, visitor: V) -> Result<Self::Value, Self::Error> fn visit_seq<V>(&mut self, visitor: V) -> Result<(), Self::Error>
where V: SeqVisitor; where V: SeqVisitor;
#[inline] #[inline]
fn visit_named_seq<V>(&mut self, fn visit_named_seq<V>(&mut self,
_name: &'static str, _name: &'static str,
visitor: V) -> Result<Self::Value, Self::Error> visitor: V) -> Result<(), Self::Error>
where V: SeqVisitor, where V: SeqVisitor,
{ {
self.visit_seq(visitor) self.visit_seq(visitor)
@ -129,7 +127,7 @@ pub trait Visitor {
fn visit_enum_seq<V>(&mut self, fn visit_enum_seq<V>(&mut self,
_name: &'static str, _name: &'static str,
_variant: &'static str, _variant: &'static str,
visitor: V) -> Result<Self::Value, Self::Error> visitor: V) -> Result<(), Self::Error>
where V: SeqVisitor, where V: SeqVisitor,
{ {
self.visit_seq(visitor) self.visit_seq(visitor)
@ -137,16 +135,16 @@ pub trait Visitor {
fn visit_seq_elt<T>(&mut self, fn visit_seq_elt<T>(&mut self,
first: bool, first: bool,
value: T) -> Result<Self::Value, Self::Error> value: T) -> Result<(), Self::Error>
where T: Serialize; where T: Serialize;
fn visit_map<V>(&mut self, visitor: V) -> Result<Self::Value, Self::Error> fn visit_map<V>(&mut self, visitor: V) -> Result<(), Self::Error>
where V: MapVisitor; where V: MapVisitor;
#[inline] #[inline]
fn visit_named_map<V>(&mut self, fn visit_named_map<V>(&mut self,
_name: &'static str, _name: &'static str,
visitor: V) -> Result<Self::Value, Self::Error> visitor: V) -> Result<(), Self::Error>
where V: MapVisitor, where V: MapVisitor,
{ {
self.visit_map(visitor) self.visit_map(visitor)
@ -156,7 +154,7 @@ pub trait Visitor {
fn visit_enum_map<V>(&mut self, fn visit_enum_map<V>(&mut self,
_name: &'static str, _name: &'static str,
_variant: &'static str, _variant: &'static str,
visitor: V) -> Result<Self::Value, Self::Error> visitor: V) -> Result<(), Self::Error>
where V: MapVisitor, where V: MapVisitor,
{ {
self.visit_map(visitor) self.visit_map(visitor)
@ -165,13 +163,13 @@ pub trait Visitor {
fn visit_map_elt<K, V>(&mut self, fn visit_map_elt<K, V>(&mut self,
first: bool, first: bool,
key: K, key: K,
value: V) -> Result<Self::Value, Self::Error> value: V) -> Result<(), Self::Error>
where K: Serialize, where K: Serialize,
V: Serialize; V: Serialize;
} }
pub trait SeqVisitor { pub trait SeqVisitor {
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: Visitor; where V: Visitor;
#[inline] #[inline]
@ -181,7 +179,7 @@ pub trait SeqVisitor {
} }
pub trait MapVisitor { pub trait MapVisitor {
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: Visitor; where V: Visitor;
#[inline] #[inline]
@ -196,7 +194,7 @@ macro_rules! impl_visit {
($ty:ty, $method:ident) => { ($ty:ty, $method:ident) => {
impl Serialize for $ty { impl Serialize for $ty {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
visitor.$method(*self) visitor.$method(*self)
@ -224,7 +222,7 @@ impl_visit!(char, visit_char);
impl<'a> Serialize for &'a str { impl<'a> Serialize for &'a str {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
visitor.visit_str(*self) visitor.visit_str(*self)
@ -233,7 +231,7 @@ impl<'a> Serialize for &'a str {
impl Serialize for String { impl Serialize for String {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(&self[..]).visit(visitor) (&self[..]).visit(visitor)
@ -244,7 +242,7 @@ impl Serialize for String {
impl<T> Serialize for Option<T> where T: Serialize { impl<T> Serialize for Option<T> where T: Serialize {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
match *self { match *self {
@ -278,7 +276,7 @@ impl<T, Iter> SeqVisitor for SeqIteratorVisitor<Iter>
Iter: Iterator<Item=T>, Iter: Iterator<Item=T>,
{ {
#[inline] #[inline]
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: Visitor, where V: Visitor,
{ {
let first = self.first; let first = self.first;
@ -305,7 +303,7 @@ impl<'a, T> Serialize for &'a [T]
where T: Serialize, where T: Serialize,
{ {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
visitor.visit_seq(SeqIteratorVisitor::new(self.iter())) visitor.visit_seq(SeqIteratorVisitor::new(self.iter()))
@ -314,7 +312,7 @@ impl<'a, T> Serialize for &'a [T]
impl<T> Serialize for Vec<T> where T: Serialize { impl<T> Serialize for Vec<T> where T: Serialize {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(&self[..]).visit(visitor) (&self[..]).visit(visitor)
@ -323,7 +321,7 @@ impl<T> Serialize for Vec<T> where T: Serialize {
impl<T> Serialize for BTreeSet<T> where T: Serialize { impl<T> Serialize for BTreeSet<T> where T: Serialize {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
visitor.visit_seq(SeqIteratorVisitor::new(self.iter())) visitor.visit_seq(SeqIteratorVisitor::new(self.iter()))
@ -335,7 +333,7 @@ impl<T, S> Serialize for HashSet<T, S>
S: HashState, S: HashState,
{ {
#[inline] #[inline]
fn visit<V: Visitor>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { fn visit<V: Visitor>(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_seq(SeqIteratorVisitor::new(self.iter())) visitor.visit_seq(SeqIteratorVisitor::new(self.iter()))
} }
} }
@ -344,7 +342,7 @@ impl<T, S> Serialize for HashSet<T, S>
impl Serialize for () { impl Serialize for () {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
visitor.visit_unit() visitor.visit_unit()
@ -384,7 +382,7 @@ macro_rules! tuple_impls {
impl<'a, $($T),+> SeqVisitor for $TupleVisitor<'a, $($T),+> impl<'a, $($T),+> SeqVisitor for $TupleVisitor<'a, $($T),+>
where $($T: Serialize),+ where $($T: Serialize),+
{ {
fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<V::Value>, V::Error> fn visit<V>(&mut self, visitor: &mut V) -> Result<Option<()>, V::Error>
where V: Visitor, where V: Visitor,
{ {
let first = self.first; let first = self.first;
@ -412,7 +410,7 @@ macro_rules! tuple_impls {
where $($T: Serialize),+ where $($T: Serialize),+
{ {
#[inline] #[inline]
fn visit<V: Visitor>(&self, visitor: &mut V) -> Result<V::Value, V::Error> { fn visit<V: Visitor>(&self, visitor: &mut V) -> Result<(), V::Error> {
visitor.visit_seq($TupleVisitor::new(self)) visitor.visit_seq($TupleVisitor::new(self))
} }
} }
@ -550,7 +548,7 @@ impl<K, V, I> MapVisitor for MapIteratorVisitor<I>
I: Iterator<Item=(K, V)>, I: Iterator<Item=(K, V)>,
{ {
#[inline] #[inline]
fn visit<V_>(&mut self, visitor: &mut V_) -> Result<Option<V_::Value>, V_::Error> fn visit<V_>(&mut self, visitor: &mut V_) -> Result<Option<()>, V_::Error>
where V_: Visitor, where V_: Visitor,
{ {
let first = self.first; let first = self.first;
@ -578,7 +576,7 @@ impl<K, V> Serialize for BTreeMap<K, V>
V: Serialize, V: Serialize,
{ {
#[inline] #[inline]
fn visit<V_: Visitor>(&self, visitor: &mut V_) -> Result<V_::Value, V_::Error> { fn visit<V_: Visitor>(&self, visitor: &mut V_) -> Result<(), V_::Error> {
visitor.visit_map(MapIteratorVisitor::new(self.iter())) visitor.visit_map(MapIteratorVisitor::new(self.iter()))
} }
} }
@ -589,7 +587,7 @@ impl<K, V, S> Serialize for HashMap<K, V, S>
S: HashState, S: HashState,
{ {
#[inline] #[inline]
fn visit<V_: Visitor>(&self, visitor: &mut V_) -> Result<V_::Value, V_::Error> { fn visit<V_: Visitor>(&self, visitor: &mut V_) -> Result<(), V_::Error> {
visitor.visit_map(MapIteratorVisitor::new(self.iter())) visitor.visit_map(MapIteratorVisitor::new(self.iter()))
} }
} }
@ -598,7 +596,7 @@ impl<K, V, S> Serialize for HashMap<K, V, S>
impl<'a, T> Serialize for &'a T where T: Serialize { impl<'a, T> Serialize for &'a T where T: Serialize {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(**self).visit(visitor) (**self).visit(visitor)
@ -607,7 +605,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> Serialize for &'a mut T where T: Serialize {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(**self).visit(visitor) (**self).visit(visitor)
@ -616,7 +614,7 @@ impl<'a, T> Serialize for &'a mut T where T: Serialize {
impl<T> Serialize for Box<T> where T: Serialize { impl<T> Serialize for Box<T> where T: Serialize {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(**self).visit(visitor) (**self).visit(visitor)
@ -625,7 +623,7 @@ impl<T> Serialize for Box<T> where T: Serialize {
impl<T> Serialize for Rc<T> where T: Serialize, { impl<T> Serialize for Rc<T> where T: Serialize, {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(**self).visit(visitor) (**self).visit(visitor)
@ -634,7 +632,7 @@ impl<T> Serialize for Rc<T> where T: Serialize, {
impl<T> Serialize for Arc<T> where T: Serialize, { impl<T> Serialize for Arc<T> where T: Serialize, {
#[inline] #[inline]
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
(**self).visit(visitor) (**self).visit(visitor)
@ -644,7 +642,7 @@ impl<T> Serialize for Arc<T> where T: Serialize, {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
impl Serialize for path::Path { impl Serialize for path::Path {
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
self.to_str().unwrap().visit(visitor) self.to_str().unwrap().visit(visitor)
@ -652,7 +650,7 @@ impl Serialize for path::Path {
} }
impl Serialize for path::PathBuf { impl Serialize for path::PathBuf {
fn visit<V>(&self, visitor: &mut V) -> Result<V::Value, V::Error> fn visit<V>(&self, visitor: &mut V) -> Result<(), V::Error>
where V: Visitor, where V: Visitor,
{ {
self.to_str().unwrap().visit(visitor) self.to_str().unwrap().visit(visitor)

View File

@ -79,7 +79,6 @@ impl<'a> AssertSerializer<'a> {
} }
impl<'a> Serializer for AssertSerializer<'a> { impl<'a> Serializer for AssertSerializer<'a> {
type Value = ();
type Error = (); type Error = ();
fn visit<T: Serialize>(&mut self, value: &T) -> Result<(), ()> { fn visit<T: Serialize>(&mut self, value: &T) -> Result<(), ()> {
@ -88,7 +87,6 @@ impl<'a> Serializer for AssertSerializer<'a> {
} }
impl<'a> Visitor for AssertSerializer<'a> { impl<'a> Visitor for AssertSerializer<'a> {
type Value = ();
type Error = (); type Error = ();
fn visit_unit(&mut self) -> Result<(), ()> { fn visit_unit(&mut self) -> Result<(), ()> {