Format with rustfmt 1.0.0-nightly
This commit is contained in:
parent
a8a54c0568
commit
9afc5fef11
@ -874,7 +874,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let visitor = VecVisitor { marker: PhantomData };
|
let visitor = VecVisitor {
|
||||||
|
marker: PhantomData,
|
||||||
|
};
|
||||||
deserializer.deserialize_seq(visitor)
|
deserializer.deserialize_seq(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1425,7 +1427,7 @@ impl<'de> Deserialize<'de> for net::IpAddr {
|
|||||||
deserializer.deserialize_str(IpAddrVisitor)
|
deserializer.deserialize_str(IpAddrVisitor)
|
||||||
} else {
|
} else {
|
||||||
use lib::net::IpAddr;
|
use lib::net::IpAddr;
|
||||||
deserialize_enum!{
|
deserialize_enum! {
|
||||||
IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
|
IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
|
||||||
"`V4` or `V6`",
|
"`V4` or `V6`",
|
||||||
deserializer
|
deserializer
|
||||||
@ -1502,7 +1504,7 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
|
|||||||
deserializer.deserialize_str(SocketAddrVisitor)
|
deserializer.deserialize_str(SocketAddrVisitor)
|
||||||
} else {
|
} else {
|
||||||
use lib::net::SocketAddr;
|
use lib::net::SocketAddr;
|
||||||
deserialize_enum!{
|
deserialize_enum! {
|
||||||
SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
|
SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
|
||||||
"`V4` or `V6`",
|
"`V4` or `V6`",
|
||||||
deserializer
|
deserializer
|
||||||
@ -1602,7 +1604,7 @@ impl<'de> Deserialize<'de> for PathBuf {
|
|||||||
// #[derive(Deserialize)]
|
// #[derive(Deserialize)]
|
||||||
// #[serde(variant_identifier)]
|
// #[serde(variant_identifier)]
|
||||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||||
variant_identifier!{
|
variant_identifier! {
|
||||||
OsStringKind (Unix; b"Unix"; 0, Windows; b"Windows"; 1)
|
OsStringKind (Unix; b"Unix"; 0, Windows; b"Windows"; 1)
|
||||||
"`Unix` or `Windows`",
|
"`Unix` or `Windows`",
|
||||||
OSSTR_VARIANTS
|
OSSTR_VARIANTS
|
||||||
@ -1760,11 +1762,7 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||||
de_rc_dst,
|
|
||||||
feature = "rc",
|
|
||||||
any(feature = "std", feature = "alloc")
|
|
||||||
))]
|
|
||||||
macro_rules! box_forwarded_impl {
|
macro_rules! box_forwarded_impl {
|
||||||
(
|
(
|
||||||
$(#[doc = $doc:tt])*
|
$(#[doc = $doc:tt])*
|
||||||
@ -1785,11 +1783,7 @@ macro_rules! box_forwarded_impl {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||||
de_rc_dst,
|
|
||||||
feature = "rc",
|
|
||||||
any(feature = "std", feature = "alloc")
|
|
||||||
))]
|
|
||||||
box_forwarded_impl! {
|
box_forwarded_impl! {
|
||||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||||
///
|
///
|
||||||
@ -1801,11 +1795,7 @@ box_forwarded_impl! {
|
|||||||
Rc
|
Rc
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||||
de_rc_dst,
|
|
||||||
feature = "rc",
|
|
||||||
any(feature = "std", feature = "alloc")
|
|
||||||
))]
|
|
||||||
box_forwarded_impl! {
|
box_forwarded_impl! {
|
||||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||||
///
|
///
|
||||||
|
@ -409,10 +409,9 @@ mod content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn end(mut self) -> Result<M::Ok, M::Error> {
|
fn end(mut self) -> Result<M::Ok, M::Error> {
|
||||||
try!(
|
try!(self
|
||||||
self.map
|
.map
|
||||||
.serialize_value(&Content::TupleStruct(self.name, self.fields))
|
.serialize_value(&Content::TupleStruct(self.name, self.fields)));
|
||||||
);
|
|
||||||
self.map.end()
|
self.map.end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,10 +453,9 @@ mod content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn end(mut self) -> Result<M::Ok, M::Error> {
|
fn end(mut self) -> Result<M::Ok, M::Error> {
|
||||||
try!(
|
try!(self
|
||||||
self.map
|
.map
|
||||||
.serialize_value(&Content::Struct(self.name, self.fields))
|
.serialize_value(&Content::Struct(self.name, self.fields)));
|
||||||
);
|
|
||||||
self.map.end()
|
self.map.end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1328,10 +1326,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<(), Self::Error> {
|
fn end(self) -> Result<(), Self::Error> {
|
||||||
try!(
|
try!(self
|
||||||
self.map
|
.map
|
||||||
.serialize_value(&Content::Struct(self.name, self.fields))
|
.serialize_value(&Content::Struct(self.name, self.fields)));
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ pub fn without_defaults(generics: &syn::Generics) -> syn::Generics {
|
|||||||
..param.clone()
|
..param.clone()
|
||||||
}),
|
}),
|
||||||
_ => param.clone(),
|
_ => param.clone(),
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
..generics.clone()
|
..generics.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,15 +169,17 @@ pub fn with_bound(
|
|||||||
associated_type_usage: Vec::new(),
|
associated_type_usage: Vec::new(),
|
||||||
};
|
};
|
||||||
match cont.data {
|
match cont.data {
|
||||||
Data::Enum(ref variants) => for variant in variants.iter() {
|
Data::Enum(ref variants) => {
|
||||||
let relevant_fields = variant
|
for variant in variants.iter() {
|
||||||
.fields
|
let relevant_fields = variant
|
||||||
.iter()
|
.fields
|
||||||
.filter(|field| filter(&field.attrs, Some(&variant.attrs)));
|
.iter()
|
||||||
for field in relevant_fields {
|
.filter(|field| filter(&field.attrs, Some(&variant.attrs)));
|
||||||
visitor.visit_field(field.original);
|
for field in relevant_fields {
|
||||||
|
visitor.visit_field(field.original);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Data::Struct(_, ref fields) => {
|
Data::Struct(_, ref fields) => {
|
||||||
for field in fields.iter().filter(|field| filter(&field.attrs, None)) {
|
for field in fields.iter().filter(|field| filter(&field.attrs, None)) {
|
||||||
visitor.visit_field(field.original);
|
visitor.visit_field(field.original);
|
||||||
@ -193,7 +196,8 @@ pub fn with_bound(
|
|||||||
.map(|id| syn::TypePath {
|
.map(|id| syn::TypePath {
|
||||||
qself: None,
|
qself: None,
|
||||||
path: id.into(),
|
path: id.into(),
|
||||||
}).chain(associated_type_usage.into_iter().cloned())
|
})
|
||||||
|
.chain(associated_type_usage.into_iter().cloned())
|
||||||
.map(|bounded_ty| {
|
.map(|bounded_ty| {
|
||||||
syn::WherePredicate::Type(syn::PredicateType {
|
syn::WherePredicate::Type(syn::PredicateType {
|
||||||
lifetimes: None,
|
lifetimes: None,
|
||||||
@ -206,7 +210,8 @@ pub fn with_bound(
|
|||||||
modifier: syn::TraitBoundModifier::None,
|
modifier: syn::TraitBoundModifier::None,
|
||||||
lifetimes: None,
|
lifetimes: None,
|
||||||
path: bound.clone(),
|
path: bound.clone(),
|
||||||
})].into_iter()
|
})]
|
||||||
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -239,7 +244,8 @@ pub fn with_self_bound(
|
|||||||
modifier: syn::TraitBoundModifier::None,
|
modifier: syn::TraitBoundModifier::None,
|
||||||
lifetimes: None,
|
lifetimes: None,
|
||||||
path: bound.clone(),
|
path: bound.clone(),
|
||||||
})].into_iter()
|
})]
|
||||||
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
}));
|
}));
|
||||||
generics
|
generics
|
||||||
@ -269,7 +275,8 @@ pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Gen
|
|||||||
syn::GenericParam::Const(_) => {}
|
syn::GenericParam::Const(_) => {}
|
||||||
}
|
}
|
||||||
param
|
param
|
||||||
})).collect();
|
}))
|
||||||
|
.collect();
|
||||||
|
|
||||||
syn::Generics {
|
syn::Generics {
|
||||||
params: params,
|
params: params,
|
||||||
@ -305,11 +312,13 @@ fn type_of_item(cont: &Container) -> syn::Type {
|
|||||||
syn::GenericParam::Const(_) => {
|
syn::GenericParam::Const(_) => {
|
||||||
panic!("Serde does not support const generics yet");
|
panic!("Serde does not support const generics yet");
|
||||||
}
|
}
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
gt_token: <Token![>]>::default(),
|
gt_token: <Token![>]>::default(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
}].into_iter()
|
}]
|
||||||
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -1369,7 +1369,8 @@ fn deserialize_adjacently_tagged_enum(
|
|||||||
quote! {
|
quote! {
|
||||||
__Field::#variant_index => #block
|
__Field::#variant_index => #block
|
||||||
}
|
}
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let expecting = format!("adjacently tagged enum {}", params.type_name());
|
let expecting = format!("adjacently tagged enum {}", params.type_name());
|
||||||
let type_name = cattrs.name().deserialize_name();
|
let type_name = cattrs.name().deserialize_name();
|
||||||
@ -1962,7 +1963,8 @@ fn deserialize_custom_identifier(
|
|||||||
variant.attrs.name().deserialize_name(),
|
variant.attrs.name().deserialize_name(),
|
||||||
variant.ident.clone(),
|
variant.ident.clone(),
|
||||||
)
|
)
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let names = names_idents.iter().map(|&(ref name, _)| name);
|
let names = names_idents.iter().map(|&(ref name, _)| name);
|
||||||
|
|
||||||
|
@ -83,21 +83,25 @@ impl<'a> Container<'a> {
|
|||||||
|
|
||||||
let mut has_flatten = false;
|
let mut has_flatten = false;
|
||||||
match data {
|
match data {
|
||||||
Data::Enum(ref mut variants) => for variant in variants {
|
Data::Enum(ref mut variants) => {
|
||||||
variant.attrs.rename_by_rule(attrs.rename_all());
|
for variant in variants {
|
||||||
for field in &mut variant.fields {
|
variant.attrs.rename_by_rule(attrs.rename_all());
|
||||||
|
for field in &mut variant.fields {
|
||||||
|
if field.attrs.flatten() {
|
||||||
|
has_flatten = true;
|
||||||
|
}
|
||||||
|
field.attrs.rename_by_rule(variant.attrs.rename_all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Data::Struct(_, ref mut fields) => {
|
||||||
|
for field in fields {
|
||||||
if field.attrs.flatten() {
|
if field.attrs.flatten() {
|
||||||
has_flatten = true;
|
has_flatten = true;
|
||||||
}
|
}
|
||||||
field.attrs.rename_by_rule(variant.attrs.rename_all());
|
field.attrs.rename_by_rule(attrs.rename_all());
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Data::Struct(_, ref mut fields) => for field in fields {
|
|
||||||
if field.attrs.flatten() {
|
|
||||||
has_flatten = true;
|
|
||||||
}
|
|
||||||
field.attrs.rename_by_rule(attrs.rename_all());
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_flatten {
|
if has_flatten {
|
||||||
@ -147,7 +151,8 @@ fn enum_from_ast<'a>(
|
|||||||
style: style,
|
style: style,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
}
|
}
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn struct_from_ast<'a>(
|
fn struct_from_ast<'a>(
|
||||||
@ -190,5 +195,6 @@ fn fields_from_ast<'a>(
|
|||||||
attrs: attr::Field::from_ast(cx, i, field, attrs, container_default),
|
attrs: attr::Field::from_ast(cx, i, field, attrs, container_default),
|
||||||
ty: &field.ty,
|
ty: &field.ty,
|
||||||
original: field,
|
original: field,
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -1372,10 +1372,12 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
seg.ident == "Cow" && args.len() == 2 && match (&args[0], &args[1]) {
|
seg.ident == "Cow"
|
||||||
(&syn::GenericArgument::Lifetime(_), &syn::GenericArgument::Type(ref arg)) => elem(arg),
|
&& args.len() == 2
|
||||||
_ => false,
|
&& match (&args[0], &args[1]) {
|
||||||
}
|
(&syn::GenericArgument::Lifetime(_), &syn::GenericArgument::Type(ref arg)) => elem(arg),
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
@ -1397,10 +1399,12 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
seg.ident == "Option" && args.len() == 1 && match args[0] {
|
seg.ident == "Option"
|
||||||
syn::GenericArgument::Type(ref arg) => elem(arg),
|
&& args.len() == 1
|
||||||
_ => false,
|
&& match args[0] {
|
||||||
}
|
syn::GenericArgument::Type(ref arg) => elem(arg),
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether the type looks like it might be `&T` where elem="T". This can have
|
// Whether the type looks like it might be `&T` where elem="T". This can have
|
||||||
@ -1492,9 +1496,11 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
|
|||||||
out.extend(ty.lifetime.iter().cloned());
|
out.extend(ty.lifetime.iter().cloned());
|
||||||
collect_lifetimes(&ty.elem, out);
|
collect_lifetimes(&ty.elem, out);
|
||||||
}
|
}
|
||||||
syn::Type::Tuple(ref ty) => for elem in &ty.elems {
|
syn::Type::Tuple(ref ty) => {
|
||||||
collect_lifetimes(elem, out);
|
for elem in &ty.elems {
|
||||||
},
|
collect_lifetimes(elem, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
syn::Type::Path(ref ty) => {
|
syn::Type::Path(ref ty) => {
|
||||||
if let Some(ref qself) = ty.qself {
|
if let Some(ref qself) = ty.qself {
|
||||||
collect_lifetimes(&qself.ty, out);
|
collect_lifetimes(&qself.ty, out);
|
||||||
|
@ -62,7 +62,8 @@ fn pretend_fields_used(cont: &Container) -> TokenStream {
|
|||||||
Some(quote!(#type_ident::#variant_ident #pat))
|
Some(quote!(#type_ident::#variant_ident #pat))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}).collect::<Vec<_>>(),
|
})
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
Data::Struct(Style::Struct, ref fields) => {
|
Data::Struct(Style::Struct, ref fields) => {
|
||||||
let pat = struct_pattern(fields);
|
let pat = struct_pattern(fields);
|
||||||
vec![quote!(#type_ident #pat)]
|
vec![quote!(#type_ident #pat)]
|
||||||
|
@ -288,7 +288,8 @@ fn serialize_tuple_struct(
|
|||||||
let field_expr = get_member(params, field, &Member::Unnamed(index));
|
let field_expr = get_member(params, field, &Member::Unnamed(index));
|
||||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
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! {
|
quote_block! {
|
||||||
let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_struct(__serializer, #type_name, #len));
|
let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_struct(__serializer, #type_name, #len));
|
||||||
@ -331,7 +332,8 @@ fn serialize_struct_as_struct(
|
|||||||
let field_expr = get_member(params, field, &field.member);
|
let field_expr = get_member(params, field, &field.member);
|
||||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
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! {
|
quote_block! {
|
||||||
let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct(__serializer, #type_name, #len));
|
let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct(__serializer, #type_name, #len));
|
||||||
@ -365,7 +367,8 @@ fn serialize_struct_as_map(
|
|||||||
let field_expr = get_member(params, field, &field.member);
|
let field_expr = get_member(params, field, &field.member);
|
||||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
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))
|
quote!(_serde::export::Some(#len))
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -386,7 +389,8 @@ fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Cont
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(variant_index, variant)| {
|
.map(|(variant_index, variant)| {
|
||||||
serialize_variant(params, variant, variant_index as u32, cattrs)
|
serialize_variant(params, variant, variant_index as u32, cattrs)
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
quote_expr! {
|
quote_expr! {
|
||||||
match *#self_var {
|
match *#self_var {
|
||||||
@ -790,7 +794,8 @@ fn serialize_tuple_variant(
|
|||||||
let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
|
let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
|
||||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
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 {
|
match context {
|
||||||
TupleVariant::ExternallyTagged {
|
TupleVariant::ExternallyTagged {
|
||||||
@ -867,7 +872,8 @@ fn serialize_struct_variant<'a>(
|
|||||||
Some(path) => quote!(if #path(#member) { 0 } else { 1 }),
|
Some(path) => quote!(if #path(#member) { 0 } else { 1 }),
|
||||||
None => quote!(1),
|
None => quote!(1),
|
||||||
}
|
}
|
||||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
})
|
||||||
|
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||||
|
|
||||||
match context {
|
match context {
|
||||||
StructVariant::ExternallyTagged {
|
StructVariant::ExternallyTagged {
|
||||||
@ -1046,7 +1052,8 @@ fn serialize_tuple_struct_visitor(
|
|||||||
None => ser,
|
None => ser,
|
||||||
Some(skip) => quote!(if !#skip { #ser }),
|
Some(skip) => quote!(if !#skip { #ser }),
|
||||||
}
|
}
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_struct_visitor(
|
fn serialize_struct_visitor(
|
||||||
@ -1140,7 +1147,8 @@ fn wrap_serialize_variant_with(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
quote!(#id)
|
quote!(#id)
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
wrap_serialize_with(
|
wrap_serialize_with(
|
||||||
params,
|
params,
|
||||||
serialize_with,
|
serialize_with,
|
||||||
|
@ -200,7 +200,7 @@ macro_rules! impl_serializer {
|
|||||||
$is_human_readable
|
$is_human_readable
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_serialize_methods!{
|
forward_serialize_methods! {
|
||||||
serialize_bool bool,
|
serialize_bool bool,
|
||||||
serialize_i8 i8,
|
serialize_i8 i8,
|
||||||
serialize_i16 i16,
|
serialize_i16 i16,
|
||||||
|
@ -351,10 +351,7 @@ struct ContainsNotDeserialize<A, B, C: DeserializeWith, E: MyDefault> {
|
|||||||
a: A,
|
a: A,
|
||||||
#[serde(skip_deserializing, default)]
|
#[serde(skip_deserializing, default)]
|
||||||
b: B,
|
b: B,
|
||||||
#[serde(
|
#[serde(deserialize_with = "DeserializeWith::deserialize_with", default)]
|
||||||
deserialize_with = "DeserializeWith::deserialize_with",
|
|
||||||
default
|
|
||||||
)]
|
|
||||||
c: C,
|
c: C,
|
||||||
#[serde(skip_deserializing, default = "MyDefault::my_default")]
|
#[serde(skip_deserializing, default = "MyDefault::my_default")]
|
||||||
e: E,
|
e: E,
|
||||||
|
@ -7,10 +7,7 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
#![cfg_attr(
|
#![cfg_attr(feature = "cargo-clippy", allow(decimal_literal_representation))]
|
||||||
feature = "cargo-clippy",
|
|
||||||
allow(decimal_literal_representation)
|
|
||||||
)]
|
|
||||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -229,7 +226,8 @@ fn assert_de_tokens_ignore(ignorable_tokens: &[Token]) {
|
|||||||
Token::Str("a"),
|
Token::Str("a"),
|
||||||
Token::I32(1),
|
Token::I32(1),
|
||||||
Token::Str("ignored"),
|
Token::Str("ignored"),
|
||||||
].into_iter()
|
]
|
||||||
|
.into_iter()
|
||||||
.chain(ignorable_tokens.to_vec().into_iter())
|
.chain(ignorable_tokens.to_vec().into_iter())
|
||||||
.chain(vec![Token::MapEnd].into_iter())
|
.chain(vec![Token::MapEnd].into_iter())
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -198,10 +198,7 @@ fn test_gen() {
|
|||||||
assert::<WithTraits1<X, X>>();
|
assert::<WithTraits1<X, X>>();
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(bound(
|
#[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))]
|
||||||
serialize = "D: SerializeWith",
|
|
||||||
deserialize = "D: DeserializeWith"
|
|
||||||
))]
|
|
||||||
struct WithTraits2<D, E> {
|
struct WithTraits2<D, E> {
|
||||||
#[serde(
|
#[serde(
|
||||||
serialize_with = "SerializeWith::serialize_with",
|
serialize_with = "SerializeWith::serialize_with",
|
||||||
@ -238,10 +235,7 @@ fn test_gen() {
|
|||||||
assert::<VariantWithTraits1<X, X>>();
|
assert::<VariantWithTraits1<X, X>>();
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(bound(
|
#[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))]
|
||||||
serialize = "D: SerializeWith",
|
|
||||||
deserialize = "D: DeserializeWith"
|
|
||||||
))]
|
|
||||||
enum VariantWithTraits2<D, E> {
|
enum VariantWithTraits2<D, E> {
|
||||||
#[serde(
|
#[serde(
|
||||||
serialize_with = "SerializeWith::serialize_with",
|
serialize_with = "SerializeWith::serialize_with",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user