Merge pull request #1669 from H2CO3/master
Allow untagged unit variants to deserialize from `Visitor::visit_none()`
This commit is contained in:
commit
ff70409215
@ -2510,6 +2510,13 @@ mod content {
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn visit_none<E>(self) -> Result<(), E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,10 @@ fn test_untagged_enum() {
|
||||
],
|
||||
);
|
||||
|
||||
// Serializes to unit, deserializes from either depending on format's
|
||||
// preference.
|
||||
assert_tokens(&Untagged::C, &[Token::Unit]);
|
||||
assert_de_tokens(&Untagged::C, &[Token::None]);
|
||||
|
||||
assert_tokens(&Untagged::D(4), &[Token::U8(4)]);
|
||||
assert_tokens(&Untagged::E("e".to_owned()), &[Token::Str("e")]);
|
||||
@ -652,11 +655,6 @@ fn test_untagged_enum() {
|
||||
],
|
||||
);
|
||||
|
||||
assert_de_tokens_error::<Untagged>(
|
||||
&[Token::None],
|
||||
"data did not match any variant of untagged enum Untagged",
|
||||
);
|
||||
|
||||
assert_de_tokens_error::<Untagged>(
|
||||
&[Token::Tuple { len: 1 }, Token::U8(1), Token::TupleEnd],
|
||||
"data did not match any variant of untagged enum Untagged",
|
||||
|
Loading…
Reference in New Issue
Block a user