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

Enable unwrap_variant_newtypes extension during serialization #336

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

juntyr
Copy link
Member

@juntyr juntyr commented Nov 16, 2021

This PR is a follow-up to #333 and implements newtype variant unwrapping during serialization (i.e. the inverse of #319). E.g.

#[derive(Serialize)]
struct Inner { x: u32 }

#[derive(Serialize)]
enum MyEnum {
    Newtype(Inner),
    ...
}

now serializes to Newtype(x: 42) instead of Newtype(Inner(x: 4.2)) or Newtype((x: 4.2)). Enabling the extension also adds the extension enabling attribute to the top of the serialized RON.

  • I've included my change in CHANGELOG.md

@juntyr juntyr marked this pull request as ready for review November 16, 2021 09:28
@juntyr
Copy link
Member Author

juntyr commented Nov 16, 2021

@torkleyy As promised, here's my follow-up to #333 so that all implemented extensions now support both serialization and deserialization.

Copy link
Contributor

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM! :shipit:

@torkleyy torkleyy merged commit c4a7834 into ron-rs:master Nov 17, 2021
@juntyr juntyr deleted the unwrap-variant-newtypes-ser branch November 17, 2021 13:51
@torkleyy torkleyy mentioned this pull request Jun 6, 2022
2 tasks
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.

2 participants