From 0020fca1842ad5bdfdd5935f88c13a34353a0046 Mon Sep 17 00:00:00 2001 From: Macpie Date: Thu, 18 Jul 2024 10:07:12 -0700 Subject: [PATCH] Fix deprecated fun --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2cddca84..84f34419 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -305,8 +305,8 @@ macro_rules! serde_enum { where S: serde::ser::Serializer, { - let v = $type::from_i32(*v) - .ok_or_else(|| serde::ser::Error::custom(format!("invalid enum value: {v}")))?; + let v = $type::try_from(*v) + .map_err(|_| serde::ser::Error::custom(format!("invalid enum value: {v}")))?; serializer.serialize_str(&v.to_string()) }