Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Add a singleton_map module for serde's 'with' attribute #300

Merged
merged 1 commit into from
Aug 2, 2022
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Aug 2, 2022

#[derive(Serialize, Deserialize)]
struct Struct {
    #[serde(with = "serde_yaml::with::singleton_map")]
    e: Enum,
}

will represent that field as a 1-element map variant: {contents} instead of the default tag-based representation !variant {contents}.

@wackazong
Copy link

I am already using #[serde(serialize_with = "some_function"] and #[serde(deserialize_with = "some_other_function"]. How can I still use this feature?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants