diff options
Diffstat (limited to 'third_party/rust/ron/src/ser/value.rs')
-rw-r--r-- | third_party/rust/ron/src/ser/value.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/third_party/rust/ron/src/ser/value.rs b/third_party/rust/ron/src/ser/value.rs new file mode 100644 index 0000000000..1a47758986 --- /dev/null +++ b/third_party/rust/ron/src/ser/value.rs @@ -0,0 +1,23 @@ +use serde::ser::{Serialize, Serializer}; + +use crate::value::{Number, Value}; + +impl Serialize for Value { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: Serializer, + { + match *self { + Value::Bool(b) => serializer.serialize_bool(b), + Value::Char(c) => serializer.serialize_char(c), + Value::Map(ref m) => Serialize::serialize(m, serializer), + Value::Number(Number::Float(ref f)) => serializer.serialize_f64(f.get()), + Value::Number(Number::Integer(i)) => serializer.serialize_i64(i), + Value::Option(Some(ref o)) => serializer.serialize_some(o.as_ref()), + Value::Option(None) => serializer.serialize_none(), + Value::String(ref s) => serializer.serialize_str(s), + Value::Seq(ref s) => Serialize::serialize(s, serializer), + Value::Unit => serializer.serialize_unit(), + } + } +} |