Cover Content::Seq case in VariantRefDeserializer::struct_variant

This commit is contained in:
Mingun 2024-08-17 15:26:59 +05:00
parent 0093f74cfe
commit 6588b0ad37
2 changed files with 21 additions and 0 deletions

View File

@ -2217,6 +2217,8 @@ mod content {
Some(Content::Map(v)) => {
de::Deserializer::deserialize_any(MapRefDeserializer::new(v), visitor)
}
// Covered by tests/test_enum_untagged.rs
// newtype_enum::struct_from_seq
Some(Content::Seq(v)) => {
de::Deserializer::deserialize_any(SeqRefDeserializer::new(v), visitor)
}

View File

@ -214,6 +214,25 @@ mod newtype_enum {
],
);
}
// Reaches crate::private::de::content::VariantRefDeserializer::struct_variant
// Content::Seq case
#[test]
fn struct_from_seq() {
assert_de_tokens(
&Outer::Inner(Inner::Struct { f: 1 }),
&[
Token::Map { len: Some(1) },
// tag
Token::Str("Struct"),
// content
Token::Seq { len: Some(1) },
Token::U8(1),
Token::SeqEnd,
Token::MapEnd,
],
);
}
}
// Reaches crate::private::de::content::ContentRefDeserializer::deserialize_option