dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
964 stars 164 forks source link

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

Closed dtolnay closed 2 years ago

dtolnay commented 2 years ago
#[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 commented 1 year ago

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