-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
A-builderArea: Builder APIArea: Builder APIC-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsE-mediumCall for participation: Experience needed to fix: Medium / intermediateCall for participation: Experience needed to fix: Medium / intermediateM-breaking-changeMeta: Implementing or merging this will introduce a breaking change.Meta: Implementing or merging this will introduce a breaking change.
Milestone
Description
Affected Version of clap
All 2.x. Breaking API change
Expected Behavior Summary
I want to decouple groups of options to several structs. I want to have a pair functions: one that adds arguments to an App with generated names, one that generates a structure with the added arguments.
Actual Behavior Summary
Uncompilable: the types don't allow to create String in a function and return a borrow.
Sample code
struct A {
...
}
impl A {
fn arguments<'a, 'b>(prefix: &str) -> Vec<Arg<'a, 'b>> {
let name = format!("{}.name", prefix);
...
}
}
Proposed solution
Since clap is dependent on its speed it's probably not an option to force 'String' instead of '&str'. However I think Cow should give enough options.
Alternative for me
Create a struct AParse
to contain the owned strings, split the function arguments
in two parts. A can generate an AParse
struct before creating the App object.
shybyte, lfrancke, joelthelion, azanar and madbonkey
Metadata
Metadata
Assignees
Labels
A-builderArea: Builder APIArea: Builder APIC-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsE-mediumCall for participation: Experience needed to fix: Medium / intermediateCall for participation: Experience needed to fix: Medium / intermediateM-breaking-changeMeta: Implementing or merging this will introduce a breaking change.Meta: Implementing or merging this will introduce a breaking change.