Skip to content

feat: add TryFrom<i32> implementation to Enumeration - #853

Merged
LucioFranco merged 3 commits into
tokio-rs:masterfrom
Leulz:fix-812
Aug 25, 2023
Merged

feat: add TryFrom<i32> implementation to Enumeration#853
LucioFranco merged 3 commits into
tokio-rs:masterfrom
Leulz:fix-812

Conversation

@Leulz

@Leulz Leulz commented Apr 25, 2023

Copy link
Copy Markdown
Contributor

Related to #812.

This allows us to more easily have generic functions that deal with conversions between i32 and prost Enums.

I took the liberty of deprecating from_i32 and updating the README.md to show how to use the TryFrom instead of from_i32. I also changed code that used from_i32 so that it uses try_from. If this is not how things are usually done in this repo, please tell me so I can undo those changes and make it so the only change is the addition of the TryFrom implementation and the new test.

Also, one point that I am not sure about is the Error type of the TryFrom implementation. I used DecodeError, but if that is not suitable and I should create a new Error struct/enum, please tell me so I can fix it.

@jgrund

jgrund commented Jul 17, 2023

Copy link
Copy Markdown

Bump, would it be possible to get this reviewed / landed?

@LucioFranco LucioFranco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Sorry for the delay, thanks for the contribution.

@0xAlcibiades

Copy link
Copy Markdown

This caused regressions in #812 #927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants