mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-11-12 02:37:06 +00:00
deserialize tuple enums with single element directly as the value instead of a sequence
This commit is contained in:
1 parent
447d08bd91
commit
5885111863
4 files changed
+91
-87
No files matched your search
@@ -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,
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user