Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(derive): Make it possible to use ArgEnum with default_value #2612

Merged
merged 1 commit into from
Jul 26, 2021

Conversation

epage
Copy link
Member

@epage epage commented Jul 21, 2021

This doesn't solve the problem end-to-end but at least makes it possible
to solve by the user and improve in the future.

/// The canonical argument value.
///
/// The value is `None` for skipped variants.
fn as_arg(&self) -> Option<&'static str>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better called as to_string or something similar? strum does something similar. https://docs.rs/strum/0.21.0/strum/derive.ToString.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • That trait allocates
  • I wanted to be clear that this conversion was to the raw argument value and not a general string conversion, which is why skiped values are not covered. People may choose to implement other traits, like Display or ToString on top of this though they have to panic or have a sentinel value when rendering a skipped value.

This doesn't solve the problem end-to-end but at least makes it possible
to solve by the user and improve in the future.
@pksunkara pksunkara merged commit 7ce5c36 into clap-rs:master Jul 26, 2021
@epage epage deleted the default_value branch July 27, 2021 17:08
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.

None yet

2 participants