Support deserialization of struct keys from integers

serde-cbor supports a "packed" serialization flag which causes keys to
be serialized as their indices, but the deserializer currently has to
hardcode support for this format. We can simply support deserialization
of struct keys from integers as we already do for enum variants.
This commit is contained in:
Steven Fackler
2017-06-17 18:09:49 -07:00
parent fd3d1396d3
commit eec7101894
2 changed files with 25 additions and 19 deletions
+11
View File
@@ -605,6 +605,17 @@ declare_tests! {
Token::StructEnd,
],
}
test_struct_integer_keys {
Struct { a: 1, b: 2, c: 0 } => &[
Token::Struct { name: "Struct", len: 2 },
Token::U32(0),
Token::I32(1),
Token::U32(1),
Token::I32(2),
Token::StructEnd,
],
}
test_enum_unit {
Enum::Unit => &[
Token::UnitVariant { name: "Enum", variant: "Unit" },