deserialize tuple enums with single element directly as the value instead of a sequence

This commit is contained in:
Oliver Schneider authored and Oliver Schneider committed 2015-07-24 09:10:58 +02:00
1 parent 447d08bd91
commit 5885111863
4 files changed
+91 -87

No files matched your search

+9
View File
@@ -571,6 +571,11 @@ pub trait VariantVisitor {
Err(Error::syntax_error())
}
/// `visit_simple` is called when deserializing a variant with a single value.
fn visit_simple<T: Deserialize>(&mut self) -> Result<T, Self::Error> {
Err(Error::syntax_error())
}
/// `visit_seq` is called when deserializing a tuple-like variant.
fn visit_seq<V>(&mut self, _visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor
@@ -601,6 +606,10 @@ impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
(**self).visit_unit()
}
fn visit_simple<D: Deserialize>(&mut self) -> Result<D, T::Error> {
(**self).visit_simple()
}
fn visit_seq<V>(&mut self, visitor: V) -> Result<V::Value, T::Error>
where V: Visitor,
{