From 0348a3914da9d4209af8f14d90e1c6894f9e541f Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 29 Jul 2015 14:05:51 -0700 Subject: [PATCH] Pass variant index to visit_enum_simple --- serde/src/ser/mod.rs | 7 ++++--- serde_codegen/src/ser.rs | 1 + serde_json/src/ser.rs | 1 + serde_json/src/value.rs | 1 + serde_tests/tests/test_bytes.rs | 1 + serde_tests/tests/test_ser.rs | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index 971cc50a..e0cc35a5 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -127,9 +127,10 @@ pub trait Serializer { #[inline] fn visit_enum_simple(&mut self, - _name: &str, - _variant: &str, - _value: T) -> Result<(), Self::Error> + name: &'static str, + variant_index: usize, + variant: &'static str, + value: T) -> Result<(), Self::Error> where T: Serialize; fn visit_none(&mut self) -> Result<(), Self::Error>; diff --git a/serde_codegen/src/ser.rs b/serde_codegen/src/ser.rs index e20a3a53..7d80f9dd 100644 --- a/serde_codegen/src/ser.rs +++ b/serde_codegen/src/ser.rs @@ -309,6 +309,7 @@ fn serialize_variant( ::serde::ser::Serializer::visit_enum_simple( serializer, $type_name, + $variant_index, $variant_name, __simple_value, ) diff --git a/serde_json/src/ser.rs b/serde_json/src/ser.rs index 5b546e3e..c1368833 100644 --- a/serde_json/src/ser.rs +++ b/serde_json/src/ser.rs @@ -174,6 +174,7 @@ impl ser::Serializer for Serializer #[inline] fn visit_enum_simple(&mut self, _name: &str, + _variant_index: usize, variant: &str, value: T, ) -> io::Result<()> diff --git a/serde_json/src/value.rs b/serde_json/src/value.rs index 794d8b21..ea40cb83 100644 --- a/serde_json/src/value.rs +++ b/serde_json/src/value.rs @@ -474,6 +474,7 @@ impl ser::Serializer for Serializer { #[inline] fn visit_enum_simple(&mut self, _name: &str, + _variant_index: usize, variant: &str, value: T, ) -> Result<(), ()> diff --git a/serde_tests/tests/test_bytes.rs b/serde_tests/tests/test_bytes.rs index c7499ffe..b6b31a6d 100644 --- a/serde_tests/tests/test_bytes.rs +++ b/serde_tests/tests/test_bytes.rs @@ -41,6 +41,7 @@ impl serde::Serializer for BytesSerializer { fn visit_enum_simple(&mut self, _name: &str, + _variant_index: usize, _variant: &str, _value: T) -> Result<(), Error> { diff --git a/serde_tests/tests/test_ser.rs b/serde_tests/tests/test_ser.rs index c667cf35..6b0d8347 100644 --- a/serde_tests/tests/test_ser.rs +++ b/serde_tests/tests/test_ser.rs @@ -84,6 +84,7 @@ impl<'a> Serializer for AssertSerializer<'a> { fn visit_enum_simple(&mut self, name: &str, + _variant_index: usize, variant: &str, value: T, ) -> Result<(), ()>