Skip to content

Add support for const_into_str attribute to enable static string conversions in const contexts#353

Merged
Peternator7 merged 5 commits intoPeternator7:masterfrom
debridge-finance:352-const-into-str
Nov 25, 2024
Merged

Add support for const_into_str attribute to enable static string conversions in const contexts#353
Peternator7 merged 5 commits intoPeternator7:masterfrom
debridge-finance:352-const-into-str

Conversation

@biryukovmaxim
Copy link
Contributor

@biryukovmaxim biryukovmaxim commented Apr 26, 2024

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:

  1. Addition of const_into_str keyword in enum metadata processing.
  2. Conditional generation of a const fn into_str() method for enums marked with const_into_str.
  3. Adjustment in the generation of the From trait to utilize into_str() when const_into_str is 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

@biryukovmaxim
Copy link
Contributor Author

@Peternator7 could you check it out?

@Peternator7
Copy link
Owner

Seems reasonable to me, could you add a test case?

@biryukovmaxim
Copy link
Contributor Author

Seems reasonable to me, could you add a test case?

Added

@lf94
Copy link

lf94 commented Aug 22, 2024

Could someone on the team merge this?

@biryukovmaxim
Copy link
Contributor Author

@Peternator7 could you take a look?

@Peternator7 Peternator7 merged commit d332030 into Peternator7:master Nov 25, 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

Development

Successfully merging this pull request may close these issues.

Support for const_into_str to Enable Static String Conversion in Const Context

3 participants