forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(derive): Specify defaults by native expressions
Right now - `default_value="something"` is a raw method - `default_value` uses native types This commit splits the meanings - `default_value="something"` is a raw method - `default_value_t` uses `T::default()` - `default_value_t=expr` uses an expression that evaluates to `T` This is meant to mirror the `value_of` / `value_of_t` API. At the moment, this is limited to `T: Display` to work with clap's default system. Something we can look at in the future is a way to loosen that restriction. One quick win is to specialize when `arg_enum` is set. The main downside is complicating the processing of attributes because it then means we need some processed before others. Since this builds on `clap`s existing default system, this also means users do not get any performance gains out of using `default_value_t`, since we still need to parse it but we also need to convert it to a string. Fixes clap-rs#1694
- Loading branch information
Showing
3 changed files
with
61 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters