From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- third_party/rust/serde_yaml/src/value/ser.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 third_party/rust/serde_yaml/src/value/ser.rs (limited to 'third_party/rust/serde_yaml/src/value/ser.rs') diff --git a/third_party/rust/serde_yaml/src/value/ser.rs b/third_party/rust/serde_yaml/src/value/ser.rs new file mode 100644 index 0000000000..f2c4bb438c --- /dev/null +++ b/third_party/rust/serde_yaml/src/value/ser.rs @@ -0,0 +1,25 @@ +use crate::Value; +use serde::Serialize; + +impl Serialize for Value { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + match self { + Value::Null => serializer.serialize_unit(), + Value::Bool(b) => serializer.serialize_bool(*b), + Value::Number(n) => n.serialize(serializer), + Value::String(s) => serializer.serialize_str(s), + Value::Sequence(seq) => seq.serialize(serializer), + Value::Mapping(hash) => { + use serde::ser::SerializeMap; + let mut map = serializer.serialize_map(Some(hash.len()))?; + for (k, v) in hash { + map.serialize_entry(k, v)?; + } + map.end() + } + } + } +} -- cgit v1.2.3