fix: loosen lifetime constraint on mut_subcommand #3909
Merged
+21
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
follow-up to PR #3882, as discussed in that PR's comments
mut_subcommand
does not resolve aliases and, if an alias name is passed forsubcmd_id
, would trigger invalid behavior as per #3888.thus to avoid this, one might resolve the alias name to the actual name before calling
mut_subcommand
, but this is currently almost impossible to do due tomut_subcommand
signature's with the'help
lifetime. specifically, looking at the test code included in this PR and without the lifetime changes, we get the following error:but loosening the lifetime constraint from
'help
to'a
resolves this.note, directly using
cmd.find_subcommand("baz").unwrap().get_name()
is invalid because of:I'd also like to do this for
mut_arg
, but that's a more involved change so will put that in a separate PR. :)