mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 05:07:56 +00:00
serialize tuple enums with single element directly as the value instead of a sequence
This commit is contained in:
@@ -471,6 +471,22 @@ impl ser::Serializer for Serializer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_enum_simple<T>(&mut self,
|
||||
_name: &str,
|
||||
variant: &str,
|
||||
value: T,
|
||||
) -> Result<(), ()>
|
||||
where T: ser::Serialize,
|
||||
{
|
||||
let mut values = BTreeMap::new();
|
||||
values.insert(variant.to_string(), to_value(&value));
|
||||
|
||||
self.state.push(State::Value(Value::Object(values)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<V>(&mut self, mut visitor: V) -> Result<(), ()>
|
||||
where V: ser::SeqVisitor,
|
||||
|
||||
Reference in New Issue
Block a user