value_of_t_or and value_of_t_or_else #3459
Labels
A-parsing
Area: Parser's logic and needs it changed somehow.
C-enhancement
Category: Raise on the bar on expectations
S-duplicate
Status: Closed as Duplicate
Please complete the following tasks
Clap Version
3.0.14
Describe your use case
The use case is the parsing of optional arguments where a default value is provided when there is none.
Currently I’m using this code:
Describe the solution you'd like
Ideally I would like something like:
and for more expensive values:
I’m actually a bit surprised something like that doesn’t exist because I though the derive feature would use something like that for
default_value_t
instead of a print/parse roundtrip.Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: