Skip to content

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

@biryukovmaxim

Description

@biryukovmaxim

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions