epage / clapng

A full featured, fast Command Line Argument Parser for Rust
docs.rs/clap
Apache License 2.0
0 stars 0 forks source link

Infer trait bounds for generic derives #243

Open epage opened 2 years ago

epage commented 2 years ago

Issue by epage Tuesday Nov 16, 2021 at 15:07 GMT Originally opened as https://github.com/clap-rs/clap/issues/3032


Building off of #2769 / #3023, we should allow inferring trait bounds.

So instead of

#[derive(Parser)]
struct Opt<T: Args> {
    #[clap(flatten)]
    inner: T,
}

The user does

#[derive(Parser)]
struct Opt<T> {
    #[clap(flatten)]
    inner: T,
}

like they do with when deriving Copy, Clone, serde types, etc.

See https://serde.rs/attr-bound.html for some inspiration on issues to deal with.