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

Support for const_into_str to Enable Static String Conversion in Const Context #352

Closed
biryukovmaxim opened this issue Apr 26, 2024 · 1 comment · Fixed by #353
Closed

Comments

@biryukovmaxim
Copy link
Contributor

Currently, the strum library does not support converting enum variants into static strings within a const context. This limitation arises because the library uses the From trait, which cannot have const methods, even in nightly Rust. This issue becomes particularly significant when attempting to use concatcp to concatenate two static strings in a const context.

To address this limitation, I propose the addition of a new enum meta attribute, const_into_str. This attribute would enable generating an additional public const function for enums, allowing conversion to static strings in a const context.

This enhancement would greatly improve strum's functionality by allowing more flexible and performant use of enums in constant expressions. I have prepared an implementation and will submit a pull request for review.

@lf94
Copy link

lf94 commented Aug 22, 2024

I hit this today. I would love if someone did this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants