Skip to content

How do I use default_value_t with an Enum? #5170

Answered by epage
crawford asked this question in Q&A
Discussion options

You must be logged in to vote

The core error message is

AorB doesn't implement std::fmt::Display

This is needed to render the default value in the help. You can use the ValueEnum trait to implement this: https://github.com/clap-rs/clap/blob/master/clap_builder/src/util/color.rs#L82

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@crawford
Comment options

@epage
Comment options

@crawford
Comment options

Answer selected by crawford
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants