Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Option<struct> in 'attribute' fields #38

Merged

Conversation

DmitrySamoylov
Copy link
Contributor

Hey @MarcAntoine-Arnaud !

Now it is possible to use Option<struct> or Option<enum> in fields marked as attribute:

  #[derive(YaDeserialize, YaSerialize, PartialEq, Debug)]
  enum AttrEnum {
    Variant1,
    Variant2,
  }

  #[derive(YaDeserialize, YaSerialize, Default, PartialEq, Debug)]
  struct Struct {
    #[yaserde(attribute)]
    attr_option_enum: Option<AttrEnum>,
  }

Corresponding XML can be like:

<?xml version="1.0" encoding="utf-8"?>
<Struct attr_option_enum="Variant2" />

@coveralls
Copy link

Pull Request Test Coverage Report for Build 117

  • 12 of 64 (18.75%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 58.065%

Changes Missing Coverage Covered Lines Changed/Added Lines %
yaserde/tests/deserializer.rs 6 8 75.0%
yaserde/tests/serializer.rs 6 9 66.67%
yaserde_derive/src/ser/expand_struct.rs 0 4 0.0%
yaserde_derive/src/field_type.rs 0 5 0.0%
yaserde_derive/src/de/expand_struct.rs 0 38 0.0%
Files with Coverage Reduction New Missed Lines %
yaserde_derive/src/de/expand_struct.rs 1 0%
yaserde_derive/src/ser/expand_struct.rs 1 0%
Totals Coverage Status
Change from base Build 116: 0.2%
Covered Lines: 864
Relevant Lines: 1488

💛 - Coveralls

@MarcAntoine-Arnaud MarcAntoine-Arnaud merged commit df67496 into media-io:master Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants