Skip to content

Commit f84e38a

Browse files
committed
fix!: Switch from &[] to IntoIterator
This is a part of clap-rs#2870 and is prep for clap-rs#1041 Oddly enough, this dropped the binary size by 200 Bytes Compared to `HEAD~` on `06_rustup`: - build: 6.21us -> 6.23us - parse: 7.55us -> 8.17us - parse_sc: 7.95us -> 7.65us
1 parent 96f91ca commit f84e38a

File tree

16 files changed

+252
-246
lines changed

16 files changed

+252
-246
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4040
built-in flags and be copied to all subcommands, instead disable
4141
the built-in flags (`Command::disable_help_flag`,
4242
`Command::disable_version_flag`) and mark the custom flags as `global(true)`.
43+
- Various `Arg`, `Command`, and `ArgGroup` calls were switched from accepting `&[]` to `[]` via `IntoIterator`
4344
- *(help)* Make `DeriveDisplayOrder` the default and removed the setting. To sort help, set `next_display_order(None)` (#2808)
4445
- *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value (#2808)
4546
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag (#3776)

Diff for: clap_bench/benches/05_ripgrep.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ where
316316
.arg(flag("help"))
317317
.arg(flag("version").short('V'))
318318
// First, set up primary positional/flag arguments.
319-
.arg(arg("pattern").required_unless_present_any(&[
319+
.arg(arg("pattern").required_unless_present_any([
320320
"file",
321321
"files",
322322
"help-short",
@@ -337,9 +337,9 @@ where
337337
flag("files")
338338
// This should also conflict with `pattern`, but the first file
339339
// path will actually be in `pattern`.
340-
.conflicts_with_all(&["file", "regexp", "type-list"]),
340+
.conflicts_with_all(["file", "regexp", "type-list"]),
341341
)
342-
.arg(flag("type-list").conflicts_with_all(&["file", "files", "pattern", "regexp"]))
342+
.arg(flag("type-list").conflicts_with_all(["file", "files", "pattern", "regexp"]))
343343
// Second, set up common flags.
344344
.arg(flag("text").short('a'))
345345
.arg(flag("count").short('c'))

Diff for: clap_bench/benches/06_rustup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn build_cli() -> Command<'static> {
263263
.action(ArgAction::SetTrue)
264264
.help("Standard library API documentation"),
265265
)
266-
.group(ArgGroup::new("page").args(&["book", "std"])),
266+
.group(ArgGroup::new("page").args(["book", "std"])),
267267
)
268268
.subcommand(
269269
Command::new("man")

Diff for: examples/tutorial_builder/04_03_relations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
.group(
1515
ArgGroup::new("vers")
1616
.required(true)
17-
.args(&["set-ver", "major", "minor", "patch"]),
17+
.args(["set-ver", "major", "minor", "patch"]),
1818
)
1919
// Arguments can also be added to a group individually, these two arguments
2020
// are part of the "input" group which is not required

Diff for: examples/tutorial_derive/04_03_relations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clap::{ArgGroup, Parser};
55
#[clap(group(
66
ArgGroup::new("vers")
77
.required(true)
8-
.args(&["set_ver", "major", "minor", "patch"]),
8+
.args(["set_ver", "major", "minor", "patch"]),
99
))]
1010
struct Cli {
1111
/// set version manually

0 commit comments

Comments
 (0)