Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

Leulz
Copy link
Contributor

@Leulz Leulz commented Apr 25, 2023

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
Copy link

jgrund commented Jul 17, 2023

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

Copy link
Member

@LucioFranco LucioFranco left a comment

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.

@LucioFranco LucioFranco merged commit ca73cbe into tokio-rs:master Aug 25, 2023
11 checks passed
@0xAlcibiades
Copy link

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.

None yet

4 participants