From 4b49f716b9af80ce8f96ad2793ef7248af3bc58b Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 1 Sep 2015 19:13:21 -0700 Subject: [PATCH] Document serde::de::impls. --- serde/src/de/impls.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 3fbce9b0..2ae1d5bf 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1,4 +1,4 @@ -#![allow(missing_docs)] +//! This module contains `Deserialize` and `Visitor` implementations. use std::borrow::Cow; use std::collections::{ @@ -41,6 +41,7 @@ use de::{ /////////////////////////////////////////////////////////////////////////////// +/// A visitor that produces a `()`. pub struct UnitVisitor; impl Visitor for UnitVisitor { @@ -69,6 +70,7 @@ impl Deserialize for () { /////////////////////////////////////////////////////////////////////////////// +/// A visitor that produces a `bool`. pub struct BoolVisitor; impl Visitor for BoolVisitor { @@ -115,11 +117,13 @@ macro_rules! impl_deserialize_num_method { } } +/// A visitor that produces a primitive type. pub struct PrimitiveVisitor { marker: PhantomData, } impl PrimitiveVisitor { + /// Construct a new `PrimitiveVisitor`. #[inline] pub fn new() -> Self { PrimitiveVisitor { @@ -302,7 +306,7 @@ impl Deserialize for Option where T: Deserialize { /////////////////////////////////////////////////////////////////////////////// -macro_rules! set_impl { +macro_rules! seq_impl { ( $ty:ty, < $($constraints:ident),* >, @@ -312,11 +316,13 @@ macro_rules! set_impl { $with_capacity:expr, $insert:expr ) => { + /// A visitor that produces a sequence. pub struct $visitor_name { marker: PhantomData, } impl $visitor_name { + /// Construct a new sequence visitor. pub fn new() -> Self { $visitor_name { marker: PhantomData, @@ -364,7 +370,7 @@ macro_rules! set_impl { } } -set_impl!( +seq_impl!( BinaryHeap, , BinaryHeapVisitor, @@ -373,7 +379,7 @@ set_impl!( BinaryHeap::with_capacity(visitor.size_hint().0), BinaryHeap::push); -set_impl!( +seq_impl!( BTreeSet, , BTreeSetVisitor, @@ -383,7 +389,7 @@ set_impl!( BTreeSet::insert); #[cfg(feature = "nightly")] -set_impl!( +seq_impl!( EnumSet, , EnumSetVisitor, @@ -392,7 +398,7 @@ set_impl!( EnumSet::new(), EnumSet::insert); -set_impl!( +seq_impl!( LinkedList, , LinkedListVisitor, @@ -401,7 +407,7 @@ set_impl!( LinkedList::new(), LinkedList::push_back); -set_impl!( +seq_impl!( HashSet, , HashSetVisitor, @@ -410,7 +416,7 @@ set_impl!( HashSet::with_capacity(visitor.size_hint().0), HashSet::insert); -set_impl!( +seq_impl!( Vec, , VecVisitor, @@ -419,7 +425,7 @@ set_impl!( Vec::with_capacity(visitor.size_hint().0), Vec::push); -set_impl!( +seq_impl!( VecDeque, , VecDequeVisitor, @@ -435,6 +441,7 @@ struct ArrayVisitor0 { } impl ArrayVisitor0 { + /// Construct a `ArrayVisitor0`. pub fn new() -> Self { ArrayVisitor0 { marker: PhantomData, @@ -479,6 +486,7 @@ macro_rules! array_impls { } impl $visitor { + /// Construct a `ArrayVisitor*`. pub fn new() -> Self { $visitor { marker: PhantomData @@ -568,6 +576,7 @@ macro_rules! tuple_impls { () => {}; ($($len:expr => $visitor:ident => ($($name:ident),+),)+) => { $( + /// Construct a tuple visitor. pub struct $visitor<$($name,)+> { marker: PhantomData<($($name,)+)>, } @@ -575,6 +584,7 @@ macro_rules! tuple_impls { impl< $($name: Deserialize,)+ > $visitor<$($name,)+> { + /// Construct a `TupleVisitor*`. pub fn new() -> Self { $visitor { marker: PhantomData } } @@ -645,11 +655,13 @@ macro_rules! map_impl { $with_capacity:expr, $insert:expr ) => { + /// A visitor that produces a map. pub struct $visitor_name { marker: PhantomData<$ty>, } impl $visitor_name { + /// Construct a `MapVisitor*`. pub fn new() -> Self { $visitor_name { marker: PhantomData,