Skip to content

Derive macro for SelectChoice trait #347

Description

@m4tx

#345 introduces a trait called SelectChoice which is essentially an enum that allows converting between a no-data enum and its string representation (see the conversation for more context: #345 (comment)).

Because it's fairly trivial to provide implementation of this trait for an enum, this makes it a perfect candidate for creating a derive macro. In fact, this functionality is also essentially what the strum crate is doing.

We should investigate whether it is possible and makes sense to use strum for this, or if not, just implement the derive macro ourselves (which shouldn't be too difficult). Note that we need some way both to override the string representation of an enum variant (id() method), and the human-friendly string displayed to the users (to_string()).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions