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

Open
biryukovmaxim opened this issue Apr 26, 2024 · 0 comments · May be fixed by #353
Open

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

biryukovmaxim opened this issue Apr 26, 2024 · 0 comments · May be fixed by #353

Comments

@biryukovmaxim
Copy link

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.

biryukovmaxim added a commit to debridge-finance/strum that referenced this issue Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant