From 94f3dd25d80d0065d1409700f1b6953c5b7f40ab Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 30 Jul 2015 20:36:15 -0700 Subject: [PATCH] Allow VariantVisitor::visit_newtype to default to calling visit_tuple --- serde/src/de/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 219b8a52..60c51edc 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -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(&mut self) -> Result 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.