This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch
dependabot/cargo/lang/rust/master/serde-1.0.183
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to
refs/heads/dependabot/cargo/lang/rust/master/serde-1.0.183 by this push:
new afa8f304d Update the Serde impl after
https://github.com/serde-rs/serde/pull/2505
afa8f304d is described below
commit afa8f304d562765f41b9ce91f6d07469b8a7e6c9
Author: Martin Tzvetanov Grigorov <[email protected]>
AuthorDate: Tue Aug 15 15:38:42 2023 +0300
Update the Serde impl after https://github.com/serde-rs/serde/pull/2505
Also see https://github.com/serde-rs/serde/issues/2496
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
---
lang/rust/avro/src/de.rs | 1 +
lang/rust/avro/src/ser.rs | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lang/rust/avro/src/de.rs b/lang/rust/avro/src/de.rs
index a2e7a0e52..610b15ae5 100644
--- a/lang/rust/avro/src/de.rs
+++ b/lang/rust/avro/src/de.rs
@@ -515,6 +515,7 @@ impl<'a, 'de> de::Deserializer<'de> for &'a
Deserializer<'de> {
match *self.input {
// This branch can be anything...
Value::Record(ref fields) =>
visitor.visit_enum(EnumDeserializer::new(fields)),
+ Value::String(ref field) =>
visitor.visit_enum(EnumUnitDeserializer::new(field)),
// This has to be a unit Enum
Value::Enum(_index, ref field) =>
visitor.visit_enum(EnumUnitDeserializer::new(field)),
_ => Err(de::Error::custom(format!(
diff --git a/lang/rust/avro/src/ser.rs b/lang/rust/avro/src/ser.rs
index 0556dc28e..f79e05866 100644
--- a/lang/rust/avro/src/ser.rs
+++ b/lang/rust/avro/src/ser.rs
@@ -200,10 +200,10 @@ impl<'b> ser::Serializer for &'b mut Serializer {
fn serialize_unit_variant(
self,
_: &'static str,
- index: u32,
+ _variant_index: u32,
variant: &'static str,
) -> Result<Self::Ok, Self::Error> {
- Ok(Value::Enum(index, variant.to_string()))
+ Ok(Value::String(variant.to_string()))
}
fn serialize_newtype_struct<T: ?Sized>(
@@ -720,7 +720,7 @@ mod tests {
a: UnitExternalEnum::Val1,
};
- let expected = Value::Record(vec![("a".to_owned(), Value::Enum(0,
"Val1".to_owned()))]);
+ let expected = Value::Record(vec![("a".to_owned(),
Value::String("Val1".to_owned()))]);
assert_eq!(
to_value(test)?,