Format with rustfmt 0.99.1
This commit is contained in:
parent
5fff0d936d
commit
28db9d4989
@ -32,8 +32,7 @@ pub fn without_defaults(generics: &syn::Generics) -> syn::Generics {
|
||||
..param.clone()
|
||||
}),
|
||||
_ => param.clone(),
|
||||
})
|
||||
.collect(),
|
||||
}).collect(),
|
||||
..generics.clone()
|
||||
}
|
||||
}
|
||||
@ -193,8 +192,7 @@ pub fn with_bound(
|
||||
.map(|id| syn::TypePath {
|
||||
qself: None,
|
||||
path: id.into(),
|
||||
})
|
||||
.chain(associated_type_usage.into_iter().cloned())
|
||||
}).chain(associated_type_usage.into_iter().cloned())
|
||||
.map(|bounded_ty| {
|
||||
syn::WherePredicate::Type(syn::PredicateType {
|
||||
lifetimes: None,
|
||||
@ -270,8 +268,7 @@ pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Gen
|
||||
syn::GenericParam::Const(_) => {}
|
||||
}
|
||||
param
|
||||
}))
|
||||
.collect();
|
||||
})).collect();
|
||||
|
||||
syn::Generics {
|
||||
params: params,
|
||||
@ -307,8 +304,7 @@ fn type_of_item(cont: &Container) -> syn::Type {
|
||||
syn::GenericParam::Const(_) => {
|
||||
panic!("Serde does not support const generics yet");
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
}).collect(),
|
||||
gt_token: <Token![>]>::default(),
|
||||
},
|
||||
),
|
||||
|
@ -204,7 +204,9 @@ fn build_generics(cont: &Container, borrowed: &BorrowedLifetimes) -> syn::Generi
|
||||
// All other fields may need a `T: Deserialize` bound where T is the type of the
|
||||
// field.
|
||||
fn needs_deserialize_bound(field: &attr::Field, variant: Option<&attr::Variant>) -> bool {
|
||||
!field.skip_deserializing() && field.deserialize_with().is_none() && field.de_bound().is_none()
|
||||
!field.skip_deserializing()
|
||||
&& field.deserialize_with().is_none()
|
||||
&& field.de_bound().is_none()
|
||||
&& variant.map_or(true, |variant| {
|
||||
!variant.skip_deserializing()
|
||||
&& variant.deserialize_with().is_none()
|
||||
@ -1350,8 +1352,7 @@ fn deserialize_adjacently_tagged_enum(
|
||||
quote! {
|
||||
__Field::#variant_index => #block
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
|
||||
let expecting = format!("adjacently tagged enum {}", params.type_name());
|
||||
let type_name = cattrs.name().deserialize_name();
|
||||
@ -1939,8 +1940,7 @@ fn deserialize_custom_identifier(
|
||||
variant.attrs.name().deserialize_name(),
|
||||
variant.ident.clone(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
|
||||
let names = names_idents.iter().map(|&(ref name, _)| name);
|
||||
|
||||
|
@ -129,8 +129,7 @@ fn enum_from_ast<'a>(
|
||||
style: style,
|
||||
fields: fields,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn struct_from_ast<'a>(
|
||||
@ -173,6 +172,5 @@ fn fields_from_ast<'a>(
|
||||
attrs: attr::Field::from_ast(cx, i, field, attrs, container_default),
|
||||
ty: &field.ty,
|
||||
original: field,
|
||||
})
|
||||
.collect()
|
||||
}).collect()
|
||||
}
|
||||
|
@ -62,8 +62,7 @@ fn pretend_fields_used(cont: &Container) -> TokenStream {
|
||||
Some(quote!(#type_ident::#variant_ident #pat))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
}).collect::<Vec<_>>(),
|
||||
Data::Struct(Style::Struct, ref fields) => {
|
||||
let pat = struct_pattern(fields);
|
||||
vec![quote!(#type_ident #pat)]
|
||||
|
@ -160,7 +160,9 @@ fn build_generics(cont: &Container) -> syn::Generics {
|
||||
// attribute specify their own bound so we do not generate one. All other fields
|
||||
// may need a `T: Serialize` bound where T is the type of the field.
|
||||
fn needs_serialize_bound(field: &attr::Field, variant: Option<&attr::Variant>) -> bool {
|
||||
!field.skip_serializing() && field.serialize_with().is_none() && field.ser_bound().is_none()
|
||||
!field.skip_serializing()
|
||||
&& field.serialize_with().is_none()
|
||||
&& field.ser_bound().is_none()
|
||||
&& variant.map_or(true, |variant| {
|
||||
!variant.skip_serializing()
|
||||
&& variant.serialize_with().is_none()
|
||||
@ -282,8 +284,7 @@ fn serialize_tuple_struct(
|
||||
let field_expr = get_member(params, field, &Member::Unnamed(index));
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
quote_block! {
|
||||
let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_struct(__serializer, #type_name, #len));
|
||||
@ -326,8 +327,7 @@ fn serialize_struct_as_struct(
|
||||
let field_expr = get_member(params, field, &field.member);
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
quote_block! {
|
||||
let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct(__serializer, #type_name, #len));
|
||||
@ -361,8 +361,7 @@ fn serialize_struct_as_map(
|
||||
let field_expr = get_member(params, field, &field.member);
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
quote!(_serde::export::Some(#len))
|
||||
};
|
||||
|
||||
@ -383,8 +382,7 @@ fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Cont
|
||||
.enumerate()
|
||||
.map(|(variant_index, variant)| {
|
||||
serialize_variant(params, variant, variant_index as u32, cattrs)
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
|
||||
quote_expr! {
|
||||
match *#self_var {
|
||||
@ -788,8 +786,7 @@ fn serialize_tuple_variant(
|
||||
let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
match context {
|
||||
TupleVariant::ExternallyTagged {
|
||||
@ -866,8 +863,7 @@ fn serialize_struct_variant<'a>(
|
||||
Some(path) => quote!(if #path(#member) { 0 } else { 1 }),
|
||||
None => quote!(1),
|
||||
}
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
match context {
|
||||
StructVariant::ExternallyTagged {
|
||||
@ -1046,8 +1042,7 @@ fn serialize_tuple_struct_visitor(
|
||||
None => ser,
|
||||
Some(skip) => quote!(if !#skip { #ser }),
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn serialize_struct_visitor(
|
||||
@ -1141,8 +1136,7 @@ fn wrap_serialize_variant_with(
|
||||
}
|
||||
};
|
||||
quote!(#id)
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
wrap_serialize_with(
|
||||
params,
|
||||
serialize_with,
|
||||
|
Loading…
Reference in New Issue
Block a user