mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 21:48:02 +00:00
Merge pull request #111 from oli-obk/master
tuple enums with single element should not be a json-array
This commit is contained in:
@@ -296,7 +296,25 @@ fn serialize_variant(
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
ast::TupleVariantKind(ref args) if args.len() == 1 => {
|
||||
let field = builder.id("__simple_value");
|
||||
let field = builder.pat().ref_id(field);
|
||||
let pat = builder.pat().enum_()
|
||||
.id(type_ident).id(variant_ident).build()
|
||||
.with_pats(Some(field).into_iter())
|
||||
.build();
|
||||
quote_arm!(cx,
|
||||
$pat => {
|
||||
::serde::ser::Serializer::visit_enum_simple(
|
||||
serializer,
|
||||
$type_name,
|
||||
$variant_name,
|
||||
__simple_value,
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
ast::TupleVariantKind(ref args) => {
|
||||
let fields: Vec<ast::Ident> = (0 .. args.len())
|
||||
.map(|i| builder.id(format!("__field{}", i)))
|
||||
|
||||
Reference in New Issue
Block a user