Skip to content

Commit

Permalink
Support ignoring enum with IgnoredAny
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 27, 2019
1 parent 1c97a7e commit e75efbf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion serde/src/de/ignored_any.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e75efbf

Please sign in to comment.