serialize tuple enums with single element directly as the value instead of a sequence

This commit is contained in:
Oliver Schneider
2015-07-17 15:19:11 +02:00
parent 5885111863
commit 24787195a1
8 changed files with 94 additions and 4 deletions
+16
View File
@@ -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,