format code
This commit is contained in:
parent
515cec5ba7
commit
7de831f27c
@ -411,9 +411,12 @@ pub fn serialize(
|
||||
}
|
||||
}
|
||||
|
||||
fn build_label_name(field: &syn::Field, field_attrs: &YaSerdeAttribute, default_namespace: &Option<String>) -> String {
|
||||
let prefix =
|
||||
if default_namespace == &field_attrs.prefix {
|
||||
fn build_label_name(
|
||||
field: &syn::Field,
|
||||
field_attrs: &YaSerdeAttribute,
|
||||
default_namespace: &Option<String>,
|
||||
) -> String {
|
||||
let prefix = if default_namespace == &field_attrs.prefix {
|
||||
"".to_string()
|
||||
} else {
|
||||
field_attrs
|
||||
@ -422,8 +425,7 @@ fn build_label_name(field: &syn::Field, field_attrs: &YaSerdeAttribute, default_
|
||||
.map_or("".to_string(), |prefix| prefix + ":")
|
||||
};
|
||||
|
||||
let label =
|
||||
field_attrs
|
||||
let label = field_attrs
|
||||
.rename
|
||||
.clone()
|
||||
.unwrap_or_else(|| field.ident.as_ref().unwrap().to_string());
|
||||
|
||||
@ -15,11 +15,12 @@ pub fn expand_derive_serialize(ast: &syn::DeriveInput) -> Result<TokenStream, St
|
||||
let root_attrs = attribute::YaSerdeAttribute::parse(attrs);
|
||||
let root = root_attrs.clone().root.unwrap_or_else(|| name.to_string());
|
||||
|
||||
let prefix =
|
||||
if root_attrs.default_namespace == root_attrs.prefix {
|
||||
let prefix = if root_attrs.default_namespace == root_attrs.prefix {
|
||||
"".to_string()
|
||||
} else {
|
||||
root_attrs.prefix.map_or("".to_string(), |prefix| prefix + ":")
|
||||
root_attrs
|
||||
.prefix
|
||||
.map_or("".to_string(), |prefix| prefix + ":")
|
||||
};
|
||||
|
||||
let root = format!("{}{}", prefix, root);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user