commit
4f78a2f701
@ -16,6 +16,9 @@ rust:
|
|||||||
- 1.47.0
|
- 1.47.0
|
||||||
- 1.48.0
|
- 1.48.0
|
||||||
- 1.49.0
|
- 1.49.0
|
||||||
|
- 1.50.0
|
||||||
|
- 1.51.0
|
||||||
|
- 1.52.0
|
||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
|
|||||||
@ -44,8 +44,7 @@ impl YaSerdeAttribute {
|
|||||||
|
|
||||||
for attr in attrs.iter().filter(|a| a.path.is_ident("yaserde")) {
|
for attr in attrs.iter().filter(|a| a.path.is_ident("yaserde")) {
|
||||||
let mut attr_iter = attr.clone().tokens.into_iter();
|
let mut attr_iter = attr.clone().tokens.into_iter();
|
||||||
if let Some(token) = attr_iter.next() {
|
if let Some(TokenTree::Group(group)) = attr_iter.next() {
|
||||||
if let TokenTree::Group(group) = token {
|
|
||||||
if group.delimiter() == Delimiter::Parenthesis {
|
if group.delimiter() == Delimiter::Parenthesis {
|
||||||
let mut attr_iter = group.stream().into_iter();
|
let mut attr_iter = group.stream().into_iter();
|
||||||
|
|
||||||
@ -94,7 +93,6 @@ impl YaSerdeAttribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
YaSerdeAttribute {
|
YaSerdeAttribute {
|
||||||
attribute,
|
attribute,
|
||||||
@ -147,7 +145,7 @@ impl YaSerdeAttribute {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
quote!(
|
quote!(
|
||||||
|
|||||||
@ -240,21 +240,17 @@ impl From<&syn::Field> for Field {
|
|||||||
impl From<&syn::PathSegment> for Field {
|
impl From<&syn::PathSegment> for Field {
|
||||||
fn from(path_segment: &syn::PathSegment) -> Self {
|
fn from(path_segment: &syn::PathSegment) -> Self {
|
||||||
if let syn::PathArguments::AngleBracketed(ref args) = path_segment.arguments {
|
if let syn::PathArguments::AngleBracketed(ref args) = path_segment.arguments {
|
||||||
if let Some(tt) = args.args.first() {
|
if let Some(syn::GenericArgument::Type(Path(ref path))) = args.args.first() {
|
||||||
if let syn::GenericArgument::Type(ref argument) = *tt {
|
|
||||||
if let Path(ref path) = *argument {
|
|
||||||
return Field::from(&path.path);
|
return Field::from(&path.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<proc_macro2::TokenStream> for Field {
|
impl From<Field> for proc_macro2::TokenStream {
|
||||||
fn into(self) -> proc_macro2::TokenStream {
|
fn from(field: Field) -> proc_macro2::TokenStream {
|
||||||
match self {
|
match field {
|
||||||
Field::FieldString => quote! { ::std::string::String },
|
Field::FieldString => quote! { ::std::string::String },
|
||||||
Field::FieldBool => quote! { bool },
|
Field::FieldBool => quote! { bool },
|
||||||
Field::FieldI8 => quote! { i8 },
|
Field::FieldI8 => quote! { i8 },
|
||||||
@ -267,14 +263,14 @@ impl Into<proc_macro2::TokenStream> for Field {
|
|||||||
Field::FieldU64 => quote! { u64 },
|
Field::FieldU64 => quote! { u64 },
|
||||||
Field::FieldF32 => quote! { f32 },
|
Field::FieldF32 => quote! { f32 },
|
||||||
Field::FieldF64 => quote! { f64 },
|
Field::FieldF64 => quote! { f64 },
|
||||||
_ => panic!("Not a simple type: {:?}", self),
|
_ => panic!("Not a simple type: {:?}", field),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<String> for &Field {
|
impl From<&Field> for String {
|
||||||
fn into(self) -> String {
|
fn from(field: &Field) -> String {
|
||||||
match self {
|
match field {
|
||||||
Field::FieldString => "str".to_string(),
|
Field::FieldString => "str".to_string(),
|
||||||
Field::FieldBool => "bool".to_string(),
|
Field::FieldBool => "bool".to_string(),
|
||||||
Field::FieldI8 => "i8".to_string(),
|
Field::FieldI8 => "i8".to_string(),
|
||||||
@ -287,7 +283,7 @@ impl Into<String> for &Field {
|
|||||||
Field::FieldU64 => "u64".to_string(),
|
Field::FieldU64 => "u64".to_string(),
|
||||||
Field::FieldF32 => "f32".to_string(),
|
Field::FieldF32 => "f32".to_string(),
|
||||||
Field::FieldF64 => "f64".to_string(),
|
Field::FieldF64 => "f64".to_string(),
|
||||||
_ => panic!("Not a simple type: {:?}", self),
|
_ => panic!("Not a simple type: {:?}", field),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ pub fn parse(
|
|||||||
.variants
|
.variants
|
||||||
.iter()
|
.iter()
|
||||||
.map(|variant| parse_variant(variant, name))
|
.map(|variant| parse_variant(variant, name))
|
||||||
.filter_map(|f| f)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let flatten = root_attributes.flatten;
|
let flatten = root_attributes.flatten;
|
||||||
@ -302,6 +302,6 @@ fn build_unnamed_visitor_calls(
|
|||||||
simple_type => call_simple_type_visitor(simple_type, set_val),
|
simple_type => call_simple_type_visitor(simple_type, set_val),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|f| f)
|
.flatten()
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ pub fn parse(
|
|||||||
build_default_value(&field, Some(type_token), value_builder)
|
build_default_value(&field, Some(type_token), value_builder)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let field_visitors: TokenStream = data_struct
|
let field_visitors: TokenStream = data_struct
|
||||||
@ -94,7 +94,7 @@ pub fn parse(
|
|||||||
let simple_type_visitor = |simple_type: Field| {
|
let simple_type_visitor = |simple_type: Field| {
|
||||||
let visitor = simple_type.get_simple_type_visitor();
|
let visitor = simple_type.get_simple_type_visitor();
|
||||||
let visitor_label = field.get_visitor_ident(None);
|
let visitor_label = field.get_visitor_ident(None);
|
||||||
let field_type: TokenStream = simple_type.into();
|
let field_type = TokenStream::from(simple_type);
|
||||||
|
|
||||||
let map_if_bool = if field_type.to_string() == "bool" {
|
let map_if_bool = if field_type.to_string() == "bool" {
|
||||||
quote!(match v {
|
quote!(match v {
|
||||||
@ -137,7 +137,7 @@ pub fn parse(
|
|||||||
simple_type => simple_type_visitor(simple_type),
|
simple_type => simple_type_visitor(simple_type),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let call_visitors: TokenStream = data_struct
|
let call_visitors: TokenStream = data_struct
|
||||||
@ -167,7 +167,7 @@ pub fn parse(
|
|||||||
|
|
||||||
let visit_simple = |simple_type: Field, action: TokenStream| {
|
let visit_simple = |simple_type: Field, action: TokenStream| {
|
||||||
let field_visitor = simple_type.get_simple_type_visitor();
|
let field_visitor = simple_type.get_simple_type_visitor();
|
||||||
let field_type: TokenStream = simple_type.into();
|
let field_type = TokenStream::from(simple_type);
|
||||||
build_call_visitor(
|
build_call_visitor(
|
||||||
&field_type,
|
&field_type,
|
||||||
&field_visitor,
|
&field_visitor,
|
||||||
@ -192,7 +192,7 @@ pub fn parse(
|
|||||||
simple_type => visit_simple(simple_type, quote! { = value }),
|
simple_type => visit_simple(simple_type, quote! { = value }),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let call_flatten_visitors: TokenStream = data_struct
|
let call_flatten_visitors: TokenStream = data_struct
|
||||||
@ -216,7 +216,7 @@ pub fn parse(
|
|||||||
field_type => unimplemented!(r#""flatten" is not implemented for {:?}"#, field_type),
|
field_type => unimplemented!(r#""flatten" is not implemented for {:?}"#, field_type),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let attributes_loading: TokenStream = data_struct
|
let attributes_loading: TokenStream = data_struct
|
||||||
@ -283,7 +283,7 @@ pub fn parse(
|
|||||||
simple_type => visit_simple(simple_type, quote! { = value }),
|
simple_type => visit_simple(simple_type, quote! { = value }),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let set_text: TokenStream = data_struct
|
let set_text: TokenStream = data_struct
|
||||||
@ -311,12 +311,12 @@ pub fn parse(
|
|||||||
},
|
},
|
||||||
Field::FieldStruct { .. } | Field::FieldVec { .. } => None,
|
Field::FieldStruct { .. } | Field::FieldVec { .. } => None,
|
||||||
simple_type => {
|
simple_type => {
|
||||||
let type_token: TokenStream = simple_type.into();
|
let type_token = TokenStream::from(simple_type);
|
||||||
set_text("e! { #type_token::from_str(text_content).unwrap() })
|
set_text("e! { #type_token::from_str(text_content).unwrap() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let struct_builder: TokenStream = data_struct
|
let struct_builder: TokenStream = data_struct
|
||||||
|
|||||||
@ -124,7 +124,7 @@ fn inner_enum_inspector(
|
|||||||
Field::FieldOption { .. } => None,
|
Field::FieldOption { .. } => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
@ -211,7 +211,7 @@ fn inner_enum_inspector(
|
|||||||
_simple_type => Some(match_field(&write_simple_type)),
|
_simple_type => Some(match_field(&write_simple_type)),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
@ -222,6 +222,6 @@ fn inner_enum_inspector(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -324,7 +324,7 @@ pub fn serialize(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
implement_serializer(
|
implement_serializer(
|
||||||
|
|||||||
@ -18,6 +18,6 @@ pub fn generate_namespaces_definition(attributes: &YaSerdeAttribute) -> TokenStr
|
|||||||
.ns(#prefix, #namespace)
|
.ns(#prefix, #namespace)
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.filter_map(|x| x)
|
.flatten()
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user