mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 11:21:01 +00:00
Merge pull request #1269 from serde-rs/with
Fix generated code for deserializing untagged newtype variant
This commit is contained in:
@@ -1802,10 +1802,8 @@ fn deserialize_untagged_newtype_variant(
|
|||||||
}
|
}
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
quote_block! {
|
quote_block! {
|
||||||
let __value: #field_ty = _serde::export::Result::map(
|
let __value: _serde::export::Result<#field_ty, _> = #path(#deserializer);
|
||||||
#path(#deserializer),
|
_serde::export::Result::map(__value, #this::#variant_ident)
|
||||||
#this::#variant_ident);
|
|
||||||
__value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -643,6 +643,16 @@ fn test_gen() {
|
|||||||
struct ImpliciltyBorrowedOption<'a> {
|
struct ImpliciltyBorrowedOption<'a> {
|
||||||
option: std::option::Option<&'a str>,
|
option: std::option::Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
enum UntaggedNewtypeVariantWith {
|
||||||
|
Newtype(
|
||||||
|
#[serde(serialize_with = "ser_x")]
|
||||||
|
#[serde(deserialize_with = "de_x")]
|
||||||
|
X,
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user