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 adding attributes to enum variants #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kriskras99
Copy link
Contributor

When dealing with serde and serde_as it can be useful to add attributes to enum variants:

#[superstruct(
    variants(V2122, V20, V19, V18),
    variant_attributes(derive(Debug, Serialize, Deserialize, Clone)),
    enum_variant_attributes(serde(borrow))
)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub struct ConfigFilesPath<'a> {
    #[superstruct(only(V20, V2122))]
    #[serde(borrow)]
    pub gachacontent: HipStr<'a>,
    #[superstruct(only(V20, V2122))]
    #[serde(borrow)]
    pub ftuesteps: HipStr<'a>,
    #[superstruct(only(V20))]
    #[serde(borrow)]
    pub anthology: HipStr<'a>,
    #[superstruct(only(V20, V2122))]
    #[serde(borrow)]
    pub objectives: HipStr<'a>,
    #[superstruct(only(V19, V20, V2122))]
    #[serde(borrow)]
    pub playlist: HipStr<'a>,
    #[superstruct(only(V20, V2122))]
    #[serde(borrow)]
    pub portraitborders: HipStr<'a>,
    #[superstruct(only(V2122))]
    #[serde(borrow)]
    pub quickplayrules: HipStr<'a>,
    #[superstruct(only(V20, V2122))]
    #[serde(borrow)]
    pub scheduledquests: HipStr<'a>,
    #[superstruct(only(V18, V19))]
    #[serde(borrow)]
    pub dmconfig: HipStr<'a>,
    #[superstruct(only(V19))]
    #[serde(borrow)]
    pub postcards: HipStr<'a>,
}

This PR does need tests, but I'm not sure how to tests this. Do you have any ideas for testing this?

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.

1 participant