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 unit_variant #62

Merged
merged 1 commit into from
Apr 19, 2021
Merged

add support for unit_variant #62

merged 1 commit into from
Apr 19, 2021

Conversation

Freax13
Copy link
Contributor

@Freax13 Freax13 commented Apr 18, 2021

This pr adds support for serializing enum unit variants with their corresponding names.
With this pr one no longer has to rely on strings for (de-)serializing enumerations.

Example:

#[derive(Serialize, Deserialize)]
pub enum Effect {
    #[serde(rename = "minecraft:overworld")]
    Overworld,
    #[serde(rename = "minecraft:the_nether")]
    Nether,
    #[serde(rename = "minecraft:the_end")]
    End,
}

(note that this example uses #[serde(rename = "...")] to rename the variants but this isn't necessarily always required)

@atheriel atheriel merged commit 3e937ec into PistonDevelopers:master Apr 19, 2021
@atheriel
Copy link
Collaborator

Looks good, thanks!

@Freax13
Copy link
Contributor Author

Freax13 commented May 15, 2021

would you mind updating the crate on crates.io?

@atheriel
Copy link
Collaborator

Should be visible shortly.

@Freax13
Copy link
Contributor Author

Freax13 commented May 15, 2021

thanks 👍

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