Replies: 2 comments 2 replies
-
An application can use either (and |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't understand, this is my code use clap::{Parser, ValueEnum};
#[derive(Debug, Default, Clone, ValueEnum)]
enum Choice {
#[default]
A,
B,
}
impl ToString for Choice {
fn to_string(&self) -> String {
match self {
Choice::A => "a".into(),
Choice::B => "b".into(),
}
}
}
#[derive(Debug, Parser)]
struct S {
#[arg(default_value_t = Choice::A)]
c: Choice,
}
fn main() {
let s = S::parse();
println!("{:?}", s);
} I would like smtg like: struct S {
#[arg(default_value_use_default_trait)]
c: Choice,
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Why not use the Default trait instead of
default_value_t = MyEnum::Variant
?Beta Was this translation helpful? Give feedback.
All reactions