Use the Default trait for enums used as options
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
It should be possible to use an `enum` as the possible value of an option, without wrapping it in an `Option` when and if the `enum` implements `Default`.
Current example :
```rust
#[derive(argh::FromArgs)]
struct Args {
/// output format
#[argh(option)]
format: Option,
}
let args: Args = argh::from_env();
let format = args.format.unwrap_or_default();
```
Using the Default trait :
```rust
#[derive(argh::FromArgs)]
struct Args {
/// output format
#[argh(option)]
format: OutputFormat, // enum should implement Default
}
```
[Case in my own code, just for context.](https://github.com/jRimbault/ddh/blob/cbcecff97202183bebaacefd5c6d60d51b0551d8/src/main.rs#L8-L37)
Contributor guide
Assessment
This issue has not been assessed yet.