strum
strum copied to clipboard
Add support for `const_into_str` attribute to enable static string conversions in const contexts
This pull request introduces the const_into_str attribute to the strum macros, enabling enums to be converted into static strings in const contexts. This feature is particularly useful when working with compile-time string manipulations, such as those required by concatcp.
Key Changes:
- Addition of
const_into_strkeyword in enum metadata processing. - Conditional generation of a
const fn into_str()method for enums marked withconst_into_str. - Adjustment in the generation of the
Fromtrait to utilizeinto_str()whenconst_into_stris enabled.
The implementation ensures that existing functionality is preserved and provides users with the option to opt into this new feature as needed. This feature could be especially beneficial for users needing efficient, compile-time safe string operations involving enums.
Please review the changes and let me know if there are any modifications or improvements required.
resolves #352
@Peternator7 could you check it out?
Seems reasonable to me, could you add a test case?
Seems reasonable to me, could you add a test case?
Added
Could someone on the team merge this?