mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
perf(derive): Reuse allocations for external subcommands
In case the `ArgMatches` is cloned, this forces a constraint that the underlying type impls `Clone` but that should be safe as we only support `String` and `OsString`.
This commit is contained in:
parent
d61552a8b8
commit
0628d04174
1 changed files with 2 additions and 1 deletions
|
@ -527,9 +527,10 @@ fn gen_from_arg_matches(
|
|||
::std::iter::once(#str_ty::from(#subcommand_name_var))
|
||||
.chain(
|
||||
#sub_arg_matches_var
|
||||
.get_many::<#str_ty>("")
|
||||
.remove_many::<#str_ty>("")
|
||||
.expect("unexpected type")
|
||||
.into_iter().flatten() // `""` isn't present, bug in `unstable-v4`
|
||||
.map(|f| ::std::sync::Arc::try_unwrap(f).unwrap_or_else(|arc| (*arc).clone()))
|
||||
.map(#str_ty::from)
|
||||
)
|
||||
.collect::<::std::vec::Vec<_>>()
|
||||
|
|
Loading…
Reference in a new issue