Extend test_internally_tagged_newtype_variant_containing_unit_struct to cover structs and seqs
This commit is contained in:
parent
3257851192
commit
b60c03ec3f
@ -1287,8 +1287,9 @@ mod content {
|
||||
// }
|
||||
//
|
||||
// We want {"topic":"Info"} to deserialize even though
|
||||
// ordinarily unit structs do not deserialize from empty map.
|
||||
// ordinarily unit structs do not deserialize from empty map/seq.
|
||||
Content::Map(ref v) if v.is_empty() => visitor.visit_unit(),
|
||||
Content::Seq(ref v) if v.is_empty() => visitor.visit_unit(),
|
||||
_ => self.deserialize_any(visitor),
|
||||
}
|
||||
}
|
||||
|
@ -1899,6 +1899,25 @@ fn test_internally_tagged_newtype_variant_containing_unit_struct() {
|
||||
Token::MapEnd,
|
||||
],
|
||||
);
|
||||
|
||||
assert_de_tokens(
|
||||
&Message::Info(Info),
|
||||
&[
|
||||
Token::Struct { name: "Message", len: 1 },
|
||||
Token::Str("topic"),
|
||||
Token::Str("Info"),
|
||||
Token::StructEnd,
|
||||
],
|
||||
);
|
||||
|
||||
assert_de_tokens(
|
||||
&Message::Info(Info),
|
||||
&[
|
||||
Token::Seq { len: Some(1) },
|
||||
Token::Str("Info"),
|
||||
Token::SeqEnd,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[deny(safe_packed_borrows)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user