diff options
author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2015-08-13 07:42:06 -0700 |
---|---|---|
committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2015-08-13 07:42:06 -0700 |
commit | b7b31bf9da36a9d8a4f7d9673c6db37ae7b87702 (patch) | |
tree | 8123db853b0aa623e6f07d89c30b6d074bafe254 | |
parent | bbc167cde968aa2ad10e97f1223b8d6ff6eaf47f (diff) | |
download | milf-rs-b7b31bf9da36a9d8a4f7d9673c6db37ae7b87702.tar.gz milf-rs-b7b31bf9da36a9d8a4f7d9673c6db37ae7b87702.zip |
Implement Serialize::visit_newtype_{struct,variant}
These functions allow a serializer to not wrap a newtyped value
inside of a tuple or struct.
-rw-r--r-- | src/encoder/serde.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/encoder/serde.rs b/src/encoder/serde.rs index 87a742e..3b50181 100644 --- a/src/encoder/serde.rs +++ b/src/encoder/serde.rs @@ -59,6 +59,24 @@ impl ser::Serializer for Encoder { try!(value.serialize(self)); Ok(()) } + fn visit_newtype_struct<T>(&mut self, + _name: &'static str, + value: T) -> Result<(), Self::Error> + where T: ser::Serialize, + { + // Don't serialize the newtype struct in a tuple. + value.serialize(self) + } + fn visit_newtype_variant<T>(&mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + value: T) -> Result<(), Self::Error> + where T: ser::Serialize, + { + // Don't serialize the newtype struct variant in a tuple. + value.serialize(self) + } } impl ser::Serialize for Value { |