Handle flatten + deserialize_with
This commit is contained in:
parent
47a4ffbd31
commit
cb2b92f828
@ -2279,8 +2279,12 @@ fn deserialize_map(
|
||||
.filter(|&&(field, _)| field.attrs.flatten())
|
||||
.map(|&(field, ref name)| {
|
||||
let field_ty = field.ty;
|
||||
let func = match field.attrs.deserialize_with() {
|
||||
None => quote!(_serde::de::Deserialize::deserialize),
|
||||
Some(path) => quote!(#path),
|
||||
};
|
||||
quote! {
|
||||
let #name: #field_ty = try!(_serde::de::Deserialize::deserialize(
|
||||
let #name: #field_ty = try!(#func(
|
||||
_serde::private::de::FlatMapDeserializer(
|
||||
&mut __collect,
|
||||
_serde::export::PhantomData)));
|
||||
|
@ -492,6 +492,13 @@ fn test_gen() {
|
||||
}
|
||||
assert_ser::<UntaggedVariantWith>();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct FlattenWith {
|
||||
#[serde(flatten, serialize_with = "ser_x", deserialize_with = "de_x")]
|
||||
x: X,
|
||||
}
|
||||
assert::<FlattenWith>();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct StaticStrStruct<'a> {
|
||||
a: &'a str,
|
||||
|
Loading…
x
Reference in New Issue
Block a user