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 <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2025-01-14 16:48:41 +01:00
parent 3ddf67eb04
commit f5adbcf1aa

View File

@ -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<usize>) -> Result<Self::SerializeSeq, Error> {
@ -554,7 +554,7 @@ impl ser::SerializeTupleVariant for SerVariant<SerArray> {
}
fn end(self) -> Result<Value, Error> {
Ok(Value::new_ref(&self.inner.array))
Ok(Value::new_ref(&self.hash))
}
}