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.
|
||||
#[inline]
|
||||
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
||||
where T: Deserialize,
|
||||
{
|
||||
let (value,) = try!(self.visit_tuple(1, impls::TupleVisitor1::new()));
|
||||
Ok(value)
|
||||
}
|
||||
where T: Deserialize;
|
||||
|
||||
/// `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::invalid_type(Type::TupleVariant))
|
||||
}
|
||||
where V: Visitor;
|
||||
|
||||
/// `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::invalid_type(Type::StructVariant))
|
||||
}
|
||||
where V: Visitor;
|
||||
}
|
||||
|
||||
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> {
|
||||
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> {
|
||||
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