Skip to content

Add EnumStringConst derive for parsing strings to enums in const contexts - #489

Open
willbuckner wants to merge 1 commit into
Peternator7:masterfrom
willbuckner:will/enum-string-const
Open

Add EnumStringConst derive for parsing strings to enums in const contexts#489
willbuckner wants to merge 1 commit into
Peternator7:masterfrom
willbuckner:will/enum-string-const

Conversation

@willbuckner

Copy link
Copy Markdown

Trait impls can't be const yet, so instead of implementing FromStr the macro generates an inherent const fn from_str_const on the enum. It matches strings using the same rules as EnumString. Only unit variants are supported since additional data can't be constructed in a const fn, and default is rejected for the same reason.

Resolves: #454

…exts

Trait impls can't be const yet, so instead of implementing FromStr the
macro generates an inherent `const fn from_str_const` on the enum. It
matches strings using the same rules as EnumString. Only unit variants
are supported since additional data can't be constructed in a const fn,
and default is rejected for the same reason.

resolves: Peternator7#454
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.

EnumString: have a const version

1 participant