Support ignoring enum with IgnoredAny

This commit is contained in:
David Tolnay 2019-06-27 10:29:48 -07:00
parent 1c97a7ecb3
commit e75efbfd31
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1,6 +1,8 @@
use lib::*;
use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
use de::{
Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor,
};
/// An efficient way of discarding data from a deserializer.
///
@ -205,6 +207,14 @@ impl<'de> Visitor<'de> for IgnoredAny {
let _ = bytes;
Ok(IgnoredAny)
}
fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
where
A: EnumAccess<'de>,
{
let (IgnoredAny, content) = data.variant()?;
content.newtype_variant()
}
}
impl<'de> Deserialize<'de> for IgnoredAny {