From f5adbcf1aae8e7d37284227a03f6d3d67d53727c Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 14 Jan 2025 16:48:41 +0100 Subject: [PATCH] fix enum serialization For tuple variants we built the hash but discarded it and returned the inner array instead. For newtype variants we returned the raw hash instead of a reference to it. Signed-off-by: Wolfgang Bumiller --- perlmod/src/ser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perlmod/src/ser.rs b/perlmod/src/ser.rs index 06f5d44..dddfa10 100644 --- a/perlmod/src/ser.rs +++ b/perlmod/src/ser.rs @@ -167,7 +167,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { let value = value.serialize(&mut Serializer)?; let hash = hash::Hash::new(); hash.insert(variant, value); - Ok(Value::from(hash)) + Ok(Value::new_ref(&hash)) } fn serialize_seq(self, len: Option) -> Result { @@ -554,7 +554,7 @@ impl ser::SerializeTupleVariant for SerVariant { } fn end(self) -> Result { - Ok(Value::new_ref(&self.inner.array)) + Ok(Value::new_ref(&self.hash)) } }