Rename de::VariantVisitor::visit_{map,seq} to visit_{struct,tuple}
This commit is contained in:
parent
7585ce9ed4
commit
351b7039a8
@ -916,11 +916,11 @@ impl<T, E> Deserialize for Result<T, E> where T: Deserialize, E: Deserialize {
|
||||
{
|
||||
match try!(visitor.visit_variant()) {
|
||||
Field::Ok => {
|
||||
let (value,) = try!(visitor.visit_seq(1, TupleVisitor1::new()));
|
||||
let (value,) = try!(visitor.visit_tuple(1, TupleVisitor1::new()));
|
||||
Ok(Ok(value))
|
||||
}
|
||||
Field::Err => {
|
||||
let (value,) = try!(visitor.visit_seq(1, TupleVisitor1::new()));
|
||||
let (value,) = try!(visitor.visit_tuple(1, TupleVisitor1::new()));
|
||||
Ok(Err(value))
|
||||
}
|
||||
}
|
||||
|
@ -584,17 +584,19 @@ pub trait VariantVisitor {
|
||||
Err(Error::syntax_error())
|
||||
}
|
||||
|
||||
/// `visit_seq` is called when deserializing a tuple-like variant.
|
||||
fn visit_seq<V>(&mut self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
|
||||
/// `visit_tuple` is called when deserializing a tuple-like variant.
|
||||
fn visit_tuple<V>(&mut self,
|
||||
_len: usize,
|
||||
_visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor
|
||||
{
|
||||
Err(Error::syntax_error())
|
||||
}
|
||||
|
||||
/// `visit_map` is called when deserializing a struct-like variant.
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
_visitor: V) -> Result<V::Value, Self::Error>
|
||||
/// `visit_struct` is called when deserializing a struct-like variant.
|
||||
fn visit_struct<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
_visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor
|
||||
{
|
||||
Err(Error::syntax_error())
|
||||
@ -618,18 +620,20 @@ impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
|
||||
(**self).visit_simple()
|
||||
}
|
||||
|
||||
fn visit_seq<V>(&mut self, len: usize, visitor: V) -> Result<V::Value, T::Error>
|
||||
fn visit_tuple<V>(&mut self,
|
||||
len: usize,
|
||||
visitor: V) -> Result<V::Value, T::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
(**self).visit_seq(len, visitor)
|
||||
(**self).visit_tuple(len, visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self,
|
||||
fn visit_struct<V>(&mut self,
|
||||
fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, T::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
(**self).visit_map(fields, visitor)
|
||||
(**self).visit_struct(fields, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,7 @@ fn deserialize_tuple_variant(
|
||||
}
|
||||
}
|
||||
|
||||
visitor.visit_seq($fields, $visitor_expr)
|
||||
visitor.visit_tuple($fields, $visitor_expr)
|
||||
})
|
||||
}
|
||||
|
||||
@ -708,7 +708,7 @@ fn deserialize_struct_variant(
|
||||
|
||||
$fields_stmt
|
||||
|
||||
visitor.visit_map(FIELDS, $visitor_expr)
|
||||
visitor.visit_struct(FIELDS, $visitor_expr)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -648,17 +648,17 @@ impl<Iter> de::VariantVisitor for Deserializer<Iter>
|
||||
de::Deserialize::deserialize(self)
|
||||
}
|
||||
|
||||
fn visit_seq<V>(&mut self,
|
||||
_len: usize,
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_tuple<V>(&mut self,
|
||||
_len: usize,
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
de::Deserializer::visit(self, visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_struct<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
de::Deserializer::visit(self, visitor)
|
||||
|
@ -753,9 +753,9 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
|
||||
de::Deserialize::deserialize(&mut Deserializer::new(self.val.take().unwrap()))
|
||||
}
|
||||
|
||||
fn visit_seq<V>(&mut self,
|
||||
_len: usize,
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_tuple<V>(&mut self,
|
||||
_len: usize,
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
if let Value::Array(fields) = self.val.take().unwrap() {
|
||||
@ -772,9 +772,9 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static[&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_struct<V>(&mut self,
|
||||
_fields: &'static[&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
if let Value::Object(fields) = self.val.take().unwrap() {
|
||||
|
@ -327,17 +327,17 @@ impl<'a> de::VariantVisitor for TokenDeserializerVariantVisitor<'a> {
|
||||
de::Deserialize::deserialize(self.de)
|
||||
}
|
||||
|
||||
fn visit_seq<V>(&mut self,
|
||||
_len: usize,
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_tuple<V>(&mut self,
|
||||
_len: usize,
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
de::Deserializer::visit(self.de, visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_struct<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
de::Deserializer::visit(self.de, visitor)
|
||||
|
Loading…
Reference in New Issue
Block a user