Rename visit_simple to visit_newtype
This commit is contained in:
parent
fefc010deb
commit
6715fb6652
@ -924,11 +924,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_simple());
|
||||
let value = try!(visitor.visit_newtype());
|
||||
Ok(Ok(value))
|
||||
}
|
||||
Field::Err => {
|
||||
let value = try!(visitor.visit_simple());
|
||||
let value = try!(visitor.visit_newtype());
|
||||
Ok(Err(value))
|
||||
}
|
||||
}
|
||||
|
@ -579,8 +579,8 @@ pub trait VariantVisitor {
|
||||
Err(Error::syntax_error())
|
||||
}
|
||||
|
||||
/// `visit_simple` is called when deserializing a variant with a single value.
|
||||
fn visit_simple<T>(&mut self) -> Result<T, Self::Error>
|
||||
/// `visit_newtype` is called when deserializing a variant with a single value.
|
||||
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
||||
where T: Deserialize,
|
||||
{
|
||||
Err(Error::syntax_error())
|
||||
@ -618,10 +618,10 @@ impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
|
||||
(**self).visit_unit()
|
||||
}
|
||||
|
||||
fn visit_simple<D>(&mut self) -> Result<D, T::Error>
|
||||
fn visit_newtype<D>(&mut self) -> Result<D, T::Error>
|
||||
where D: Deserialize,
|
||||
{
|
||||
(**self).visit_simple()
|
||||
(**self).visit_newtype()
|
||||
}
|
||||
|
||||
fn visit_tuple<V>(&mut self,
|
||||
|
@ -574,7 +574,7 @@ fn deserialize_variant(
|
||||
}
|
||||
ast::TupleVariantKind(ref args) if args.len() == 1 => {
|
||||
quote_expr!(cx, {
|
||||
let val = try!(visitor.visit_simple());
|
||||
let val = try!(visitor.visit_newtype());
|
||||
Ok($type_ident::$variant_ident(val))
|
||||
})
|
||||
}
|
||||
|
@ -644,7 +644,9 @@ impl<Iter> de::VariantVisitor for Deserializer<Iter>
|
||||
de::Deserialize::deserialize(self)
|
||||
}
|
||||
|
||||
fn visit_simple<T: de::Deserialize>(&mut self) -> Result<T, Error> {
|
||||
fn visit_newtype<T>(&mut self) -> Result<T, Error>
|
||||
where T: de::Deserialize,
|
||||
{
|
||||
de::Deserialize::deserialize(self)
|
||||
}
|
||||
|
||||
|
@ -747,7 +747,7 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
|
||||
de::Deserialize::deserialize(&mut Deserializer::new(self.val.take().unwrap()))
|
||||
}
|
||||
|
||||
fn visit_simple<T>(&mut self) -> Result<T, Error>
|
||||
fn visit_newtype<T>(&mut self) -> Result<T, Error>
|
||||
where T: de::Deserialize,
|
||||
{
|
||||
de::Deserialize::deserialize(&mut Deserializer::new(self.val.take().unwrap()))
|
||||
|
@ -40,7 +40,7 @@ enum Token {
|
||||
|
||||
EnumStart(&'static str),
|
||||
EnumUnit,
|
||||
EnumSimple,
|
||||
EnumNewtype,
|
||||
EnumSeq,
|
||||
EnumMap,
|
||||
EnumEnd,
|
||||
@ -339,11 +339,11 @@ impl<'a> de::VariantVisitor for TokenDeserializerVariantVisitor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_simple<T>(&mut self) -> Result<T, Self::Error>
|
||||
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
|
||||
where T: de::Deserialize,
|
||||
{
|
||||
match self.de.tokens.next() {
|
||||
Some(Token::EnumSimple) => {
|
||||
Some(Token::EnumNewtype) => {
|
||||
de::Deserialize::deserialize(self.de)
|
||||
}
|
||||
Some(_) => Err(Error::SyntaxError),
|
||||
@ -541,7 +541,7 @@ declare_tests! {
|
||||
Token::EnumStart("Result"),
|
||||
Token::Str("Ok"),
|
||||
|
||||
Token::EnumSimple,
|
||||
Token::EnumNewtype,
|
||||
Token::I32(0),
|
||||
Token::SeqEnd,
|
||||
],
|
||||
@ -549,7 +549,7 @@ declare_tests! {
|
||||
Token::EnumStart("Result"),
|
||||
Token::Str("Err"),
|
||||
|
||||
Token::EnumSimple,
|
||||
Token::EnumNewtype,
|
||||
Token::I32(1),
|
||||
Token::SeqEnd,
|
||||
],
|
||||
@ -934,7 +934,7 @@ declare_tests! {
|
||||
Token::EnumStart("Enum"),
|
||||
Token::Str("Simple"),
|
||||
|
||||
Token::EnumSimple,
|
||||
Token::EnumNewtype,
|
||||
Token::I32(1),
|
||||
Token::EnumEnd,
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user