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 #[serde(with)] for containers #2515

Closed
wants to merge 1 commit into from

Conversation

oblique
Copy link

@oblique oblique commented Jul 18, 2023

Why this is useful:

  • It will enable #[serde_with::serde_as(as = "SomeSerdeWithUtil")] to be applied on a container.

  • It can be easily used with code-generators such as prost-build. For example:

    prost_build::Config::new()
        .type_attribute(
            "my_messages.MyMessageType",
            "#[derive(Serialize, Deserialize)] #[serde(with = \"my_message_type\")]",
        )
        .complie_protos(&["my_messages.proto"])
        .unwrap();

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I would prefer not to build this into serde_derive. But if it's helpful to have reusable code for producing these 1-line impls, someone could factor the needed parts out into its own macro crate.

@dtolnay dtolnay closed this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants