Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifetime of possible values and PossibleValueParser #4035

Closed
2 tasks done
liningpan opened this issue Aug 7, 2022 · 2 comments
Closed
2 tasks done

Lifetime of possible values and PossibleValueParser #4035

liningpan opened this issue Aug 7, 2022 · 2 comments
Labels
A-builder Area: Builder API C-bug Category: Updating dependencies M-breaking-change Meta: Implementing or merging this will introduce a breaking change. S-blocked Status: Blocked on something else such as an RFC or other implementation work.
Milestone

Comments

@liningpan
Copy link

Please complete the following tasks

Rust Version

rustc 1.62.1 (e092d0b6b 2022-07-16)

Clap Version

3.2.16

Minimal reproducible code

use clap::{command, Arg};

fn main() {
    let possible_values: Vec<&str> = vec!["abc", "def"];
    let app = command!().arg(Arg::new("example").possible_values(&possible_values));
    let matches = app.get_matches();
    println!("{:#?}", matches);
}

Steps to reproduce the bug with the above code

I'm trying to build a dynamic command line interface, where possible options are read from a config file. This is currently possible as .possible_values() requires 'help lifetime, but the new PossibleValueParser implementation requires 'static lifetime.

Actual Behaviour

N/A

Expected Behaviour

N/A

Additional Context

No response

Debug Output

No response

@liningpan liningpan added the C-bug Category: Updating dependencies label Aug 7, 2022
@epage epage added A-builder Area: Builder API S-blocked Status: Blocked on something else such as an RFC or other implementation work. M-breaking-change Meta: Implementing or merging this will introduce a breaking change. labels Aug 9, 2022
@epage epage added this to the 4.0 milestone Aug 9, 2022
@epage
Copy link
Member

epage commented Aug 9, 2022

We can't add lifetimes to PossibleValueParser without a breaking change and on next breaking change, we're hoping to remove lifetimes completely, see #1041.

@epage
Copy link
Member

epage commented Aug 22, 2022

Resolved in #4097

@epage epage closed this as completed Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builder Area: Builder API C-bug Category: Updating dependencies M-breaking-change Meta: Implementing or merging this will introduce a breaking change. S-blocked Status: Blocked on something else such as an RFC or other implementation work.
Projects
None yet
Development

No branches or pull requests

2 participants