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

Implement my traits on generated Enum #1185

Open
dimitri-correia opened this issue Nov 9, 2024 · 1 comment
Open

Implement my traits on generated Enum #1185

dimitri-correia opened this issue Nov 9, 2024 · 1 comment

Comments

@dimitri-correia
Copy link

Problem Description

I'm trying to iterate over the values of an enum generated by Prost, which is something I typically achieve using the Strum crate with the EnumIter trait. However, since the enum is generated by Prost (prost-build), I can't directly use Strum here.

What I’ve Tried

I looked for a way to iterate over the Prost-generated enum, but it seems that this isn’t currently supported, or at least I couldn’t find a method. My workaround idea was to add the enum manually in my Rust code rather than defining it in my .proto file, using "Tag Inference for Existing Types" with use prost::{Enumeration, Message};. However, this leads to errors since the .proto file requires the enum to be defined within it.

Proposal

Could we consider adding a feature flag in Prost to allow additional traits on enums, such as an iterator? This would make it easier to iterate over enums generated from .proto files without additional workarounds.
I can start to look into creating a PR for this, but I want to be sure it's something that is wanted and possible to achieve.

What are your thoughts on this?

@caspermeijn
Copy link
Collaborator

caspermeijn commented Nov 9, 2024 via email

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

No branches or pull requests

2 participants