Skip to content

Commit

Permalink
Fix deprecated fun
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie committed Jul 18, 2024
1 parent 58465ac commit 0020fca
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 @@ -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())
}

Expand Down

0 comments on commit 0020fca

Please sign in to comment.