Skip to content

Commit

Permalink
Cover Content::Seq case in VariantRefDeserializer::struct_variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Aug 23, 2024
1 parent 0093f74 commit 6588b0a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions serde/src/private/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
19 changes: 19 additions & 0 deletions test_suite/tests/test_enum_untagged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6588b0a

Please sign in to comment.