mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 02:01:03 +00:00
Support consolidated with attribute for variants
This commit is contained in:
@@ -573,6 +573,18 @@ impl Variant {
|
|||||||
other.set_true();
|
other.set_true();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse `#[serde(with = "...")]`
|
||||||
|
MetaItem(NameValue(ref name, ref lit)) if name == "with" => {
|
||||||
|
if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) {
|
||||||
|
let mut ser_path = path.clone();
|
||||||
|
ser_path.segments.push("serialize".into());
|
||||||
|
serialize_with.set(ser_path);
|
||||||
|
let mut de_path = path;
|
||||||
|
de_path.segments.push("deserialize".into());
|
||||||
|
deserialize_with.set(de_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parse `#[serde(serialize_with = "...")]`
|
// Parse `#[serde(serialize_with = "...")]`
|
||||||
MetaItem(NameValue(ref name, ref lit)) if name == "serialize_with" => {
|
MetaItem(NameValue(ref name, ref lit)) if name == "serialize_with" => {
|
||||||
if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) {
|
if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) {
|
||||||
|
|||||||
Reference in New Issue
Block a user