Allow untagged unit variants to deserialize from Visitor::visit_none()

This commit is contained in:
Árpád Goretity 2019-11-06 17:31:27 +01:00
parent 4eb580790d
commit 6e2c385fa5
2 changed files with 16 additions and 0 deletions

View File

@ -2510,6 +2510,13 @@ mod content {
{
Ok(())
}
fn visit_none<E>(self) -> Result<(), E>
where
E: de::Error,
{
Ok(())
}
}
}

View File

@ -137,6 +137,12 @@ enum EnumOther {
Other,
}
#[derive(PartialEq, Debug, Deserialize)]
#[serde(untagged)]
enum EnumUntaggedUnit {
Unit,
}
#[derive(PartialEq, Debug)]
struct IgnoredAny;
@ -788,6 +794,9 @@ declare_tests! {
Token::Unit,
],
}
test_enum_untagged_unit_from_none {
UntaggedUnit::Unit => &[Token::None],
}
test_box {
Box::new(0i32) => &[Token::I32(0)],
}