Allow VariantVisitor::visit_newtype to default to calling visit_tuple

This commit is contained in:
Erick Tryzelaar 2015-07-30 20:36:15 -07:00
parent 2c58a9c11d
commit 94f3dd25d8

View File

@ -596,11 +596,14 @@ pub trait VariantVisitor {
Err(Error::syntax_error())
}
/// `visit_newtype` is called when deserializing a variant with a single value.
/// `visit_newtype` is called when deserializing a variant with a single value. By default this
/// uses the `visit_tuple` method to deserialize the value.
#[inline]
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
where T: Deserialize,
{
Err(Error::syntax_error())
let (value,) = try!(self.visit_tuple(1, impls::TupleVisitor1::new()));
Ok(value)
}
/// `visit_tuple` is called when deserializing a tuple-like variant.