mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-27 01:11:38 +00:00
Added Serde Serialize/Deserialize traits
This commit is contained in:
parent
6ca43ce46f
commit
b3ac95e814
@ -21,6 +21,8 @@ pub fn expand_struct(strct: &Struct, actual_derives: &mut Option<TokenStream>) -
|
||||
Trait::Ord => expanded.extend(struct_ord(strct, span)),
|
||||
Trait::PartialEq => traits.push(quote_spanned!(span=> ::std::cmp::PartialEq)),
|
||||
Trait::PartialOrd => expanded.extend(struct_partial_ord(strct, span)),
|
||||
Trait::Serialize => traits.push(quote_spanned!(span=> serde::Serialize)),
|
||||
Trait::Deserialize => traits.push(quote_spanned!(span=> serde::Deserialize)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,6 +68,8 @@ pub fn expand_enum(enm: &Enum, actual_derives: &mut Option<TokenStream>) -> Toke
|
||||
has_partial_eq = true;
|
||||
}
|
||||
Trait::PartialOrd => expanded.extend(enum_partial_ord(enm, span)),
|
||||
Trait::Serialize => traits.push(quote_spanned!(span=> serde::Serialize)),
|
||||
Trait::Deserialize => traits.push(quote_spanned!(span=> serde::Deserialize)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@ pub enum Trait {
|
||||
Ord,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
}
|
||||
|
||||
impl Derive {
|
||||
@ -34,6 +36,8 @@ impl Derive {
|
||||
"Ord" => Trait::Ord,
|
||||
"PartialEq" => Trait::PartialEq,
|
||||
"PartialOrd" => Trait::PartialOrd,
|
||||
"Serialize" => Trait::Serialize,
|
||||
"Deserialize" => Trait::Deserialize,
|
||||
_ => return None,
|
||||
};
|
||||
let span = ident.span();
|
||||
@ -60,6 +64,8 @@ impl AsRef<str> for Trait {
|
||||
Trait::Ord => "Ord",
|
||||
Trait::PartialEq => "PartialEq",
|
||||
Trait::PartialOrd => "PartialOrd",
|
||||
Trait::Serialize => "Serialize",
|
||||
Trait::Deserialize => "Deserialize",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user