make VariantVisitor
pure
This commit is contained in:
parent
36a7bf6244
commit
4722571a4d
@ -846,29 +846,19 @@ pub trait VariantVisitor {
|
|||||||
/// uses the `visit_tuple` method to deserialize the value.
|
/// uses the `visit_tuple` method to deserialize the value.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
||||||
where T: Deserialize,
|
where T: Deserialize;
|
||||||
{
|
|
||||||
let (value,) = try!(self.visit_tuple(1, impls::TupleVisitor1::new()));
|
|
||||||
Ok(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `visit_tuple` is called when deserializing a tuple-like variant.
|
/// `visit_tuple` is called when deserializing a tuple-like variant.
|
||||||
fn visit_tuple<V>(&mut self,
|
fn visit_tuple<V>(&mut self,
|
||||||
_len: usize,
|
_len: usize,
|
||||||
_visitor: V) -> Result<V::Value, Self::Error>
|
_visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where V: Visitor
|
where V: Visitor;
|
||||||
{
|
|
||||||
Err(Error::invalid_type(Type::TupleVariant))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `visit_struct` is called when deserializing a struct-like variant.
|
/// `visit_struct` is called when deserializing a struct-like variant.
|
||||||
fn visit_struct<V>(&mut self,
|
fn visit_struct<V>(&mut self,
|
||||||
_fields: &'static [&'static str],
|
_fields: &'static [&'static str],
|
||||||
_visitor: V) -> Result<V::Value, Self::Error>
|
_visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where V: Visitor
|
where V: Visitor;
|
||||||
{
|
|
||||||
Err(Error::invalid_type(Type::StructVariant))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
|
impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
|
||||||
|
@ -338,6 +338,29 @@ impl<'a, E> de::VariantVisitor for StrDeserializer<'a, E>
|
|||||||
fn visit_unit(&mut self) -> Result<(), Self::Error> {
|
fn visit_unit(&mut self) -> Result<(), Self::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
||||||
|
where T: super::Deserialize,
|
||||||
|
{
|
||||||
|
let (value,) = try!(self.visit_tuple(1, super::impls::TupleVisitor1::new()));
|
||||||
|
Ok(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_tuple<V>(&mut self,
|
||||||
|
_len: usize,
|
||||||
|
_visitor: V) -> Result<V::Value, Self::Error>
|
||||||
|
where V: super::Visitor
|
||||||
|
{
|
||||||
|
Err(super::Error::invalid_type(super::Type::TupleVariant))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_struct<V>(&mut self,
|
||||||
|
_fields: &'static [&'static str],
|
||||||
|
_visitor: V) -> Result<V::Value, Self::Error>
|
||||||
|
where V: super::Visitor
|
||||||
|
{
|
||||||
|
Err(super::Error::invalid_type(super::Type::StructVariant))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -413,6 +436,29 @@ impl<'a, E> de::VariantVisitor for StringDeserializer<E>
|
|||||||
fn visit_unit(&mut self) -> Result<(), Self::Error> {
|
fn visit_unit(&mut self) -> Result<(), Self::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
||||||
|
where T: super::Deserialize,
|
||||||
|
{
|
||||||
|
let (value,) = try!(self.visit_tuple(1, super::impls::TupleVisitor1::new()));
|
||||||
|
Ok(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_tuple<V>(&mut self,
|
||||||
|
_len: usize,
|
||||||
|
_visitor: V) -> Result<V::Value, Self::Error>
|
||||||
|
where V: super::Visitor
|
||||||
|
{
|
||||||
|
Err(super::Error::invalid_type(super::Type::TupleVariant))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_struct<V>(&mut self,
|
||||||
|
_fields: &'static [&'static str],
|
||||||
|
_visitor: V) -> Result<V::Value, Self::Error>
|
||||||
|
where V: super::Visitor
|
||||||
|
{
|
||||||
|
Err(super::Error::invalid_type(super::Type::StructVariant))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user