Skip to content

Commit

Permalink
Fix deprecated from_i32 for proto enum
Browse files Browse the repository at this point in the history
  • Loading branch information
madninja committed Oct 18, 2023
1 parent e08125a commit 622faee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,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())
}

Expand Down

0 comments on commit 622faee

Please sign in to comment.