You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change expected enum representation in tests according to new policy
New representation policy is compatible with serde>=1.0.181 and also more correct
and consistent with general mapping rules.
General rules of new policy:
- In `$value` field the representation is always the same as top-level representation;
- In `$text` field the representation is always the same as in normal field, but surrounding tags with field name are removed;
- In normal field the representation is always contains a tag with field name.
The tables below summarizes the representation policy. For examples in fields only content
at place of `...` is shown:
```
<Container>...</Container>
```
The struct which contains field looks like:
```
struct Container {
field: Enum,
#[serde(rename = "$text")]
text: Enum,
#[serde(rename = "$value")]
value: Enum,
}
```
Normal enum variant
-------------------
### Old (before this commit) representation
|Kind |Top-level, in normal and `$value` fields |In `$text` field|
|-------|-----------------------------------------|----------------|
|Unit |`<Unit/>` |_(empty)_ |
|Newtype|`<Newtype>42</Newtype>` |`42` |
|Tuple |`<Tuple>42</Tuple><Tuple>answer</Tuple>` |`42 answer` |
|Struct |`<Struct><q>42</q><a>answer</a></Struct>`|Err(Unsupported)|
### New (since this commit)
|Kind |Top-level and in `$value` field |In normal field |In `$text` field|
|-------|-----------------------------------------|---------------------|----------------|
|Unit |`<Unit/>` |`<field>Unit</field>`|`Unit` |
|Newtype|`<Newtype>42</Newtype>` |Err(Unsupported) |Err(Unsupported)|
|Tuple |`<Tuple>42</Tuple><Tuple>answer</Tuple>` |Err(Unsupported) |Err(Unsupported)|
|Struct |`<Struct><q>42</q><a>answer</a></Struct>`|Err(Unsupported) |Err(Unsupported)|
`$text` enum variant
--------------------
`<field>` in top-level serialization is the name of top-level element, serialization is impossible if it is not defined in the serializer.
### Old (before this commit) representation
|Kind |In `$value` field |In normal field |In `$text` field|
|-------|-------------------------------|--------------------------|----------------|
|Unit |_(empty)_ |`<field/>` |_(empty)_ |
|Newtype|`42` |`<field>42</field>` |`42` |
|Tuple |`42 answer` |`<field>42 answer</field>`|`42 answer` |
|Struct |Err(Unsupported) |Err(Unsupported) |Err(Unsupported)|
### New (since this commit)
|Kind |Top-level and in `$value` field|In normal field |In `$text` field|
|-------|-------------------------------|--------------------------|----------------|
|Unit |_(empty)_ |`<field/>` |_(empty)_ |
|Newtype|`42` |Err(Unsupported) |Err(Unsupported)|
|Tuple |`42 answer` |Err(Unsupported) |Err(Unsupported)|
|Struct |Err(Unsupported) |Err(Unsupported) |Err(Unsupported)|
failures (28):
--lib (14)
se::element::tests::expand_empty_elements::enum_unit
se::element::tests::expand_empty_elements::enum_unit_escaped
se::element::tests::with_indent::attributes::enum_
se::element::tests::with_indent::enum_newtype
se::element::tests::with_indent::enum_struct
se::element::tests::with_indent::enum_tuple
se::element::tests::with_indent::enum_unit
se::element::tests::with_indent::enum_unit_escaped
se::element::tests::without_indent::attributes::enum_
se::element::tests::without_indent::enum_newtype
se::element::tests::without_indent::enum_struct
se::element::tests::without_indent::enum_tuple
se::element::tests::without_indent::enum_unit
se::element::tests::without_indent::enum_unit_escaped
serde-se (14):
without_root::enum_::externally_tagged::normal_field2::empty_struct
without_root::enum_::externally_tagged::normal_field2::newtype
without_root::enum_::externally_tagged::normal_field2::struct_
without_root::enum_::externally_tagged::normal_field2::tuple
without_root::enum_::externally_tagged::normal_field2::unit
without_root::enum_::externally_tagged::normal_field::empty_struct
without_root::enum_::externally_tagged::normal_field::newtype
without_root::enum_::externally_tagged::normal_field::struct_
without_root::enum_::externally_tagged::normal_field::tuple
without_root::enum_::externally_tagged::normal_field::unit
without_root::enum_::externally_tagged::text_variant::normal_field::newtype
without_root::enum_::externally_tagged::text_variant::normal_field::tuple
without_root::enum_::externally_tagged::text_variant::normal_field::unit
without_root::enum_::externally_tagged::text_variant::text_field::unit
0 commit comments