Skip to content

Commit

Permalink
fix!: Switch from &[] to IntoIterator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
epage committed Aug 12, 2022
1 parent 96f91ca commit f84e38a
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 246 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
built-in flags and be copied to all subcommands, instead disable
the built-in flags (`Command::disable_help_flag`,
`Command::disable_version_flag`) and mark the custom flags as `global(true)`.
- Various `Arg`, `Command`, and `ArgGroup` calls were switched from accepting `&[]` to `[]` via `IntoIterator`
- *(help)* Make `DeriveDisplayOrder` the default and removed the setting. To sort help, set `next_display_order(None)` (#2808)
- *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value (#2808)
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag (#3776)
Expand Down
6 changes: 3 additions & 3 deletions clap_bench/benches/05_ripgrep.rs
Expand Up @@ -316,7 +316,7 @@ where
.arg(flag("help"))
.arg(flag("version").short('V'))
// First, set up primary positional/flag arguments.
.arg(arg("pattern").required_unless_present_any(&[
.arg(arg("pattern").required_unless_present_any([
"file",
"files",
"help-short",
Expand All @@ -337,9 +337,9 @@ where
flag("files")
// This should also conflict with `pattern`, but the first file
// path will actually be in `pattern`.
.conflicts_with_all(&["file", "regexp", "type-list"]),
.conflicts_with_all(["file", "regexp", "type-list"]),
)
.arg(flag("type-list").conflicts_with_all(&["file", "files", "pattern", "regexp"]))
.arg(flag("type-list").conflicts_with_all(["file", "files", "pattern", "regexp"]))
// Second, set up common flags.
.arg(flag("text").short('a'))
.arg(flag("count").short('c'))
Expand Down
2 changes: 1 addition & 1 deletion clap_bench/benches/06_rustup.rs
Expand Up @@ -263,7 +263,7 @@ fn build_cli() -> Command<'static> {
.action(ArgAction::SetTrue)
.help("Standard library API documentation"),
)
.group(ArgGroup::new("page").args(&["book", "std"])),
.group(ArgGroup::new("page").args(["book", "std"])),
)
.subcommand(
Command::new("man")
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_builder/04_03_relations.rs
Expand Up @@ -14,7 +14,7 @@ fn main() {
.group(
ArgGroup::new("vers")
.required(true)
.args(&["set-ver", "major", "minor", "patch"]),
.args(["set-ver", "major", "minor", "patch"]),
)
// Arguments can also be added to a group individually, these two arguments
// are part of the "input" group which is not required
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_derive/04_03_relations.rs
Expand Up @@ -5,7 +5,7 @@ use clap::{ArgGroup, Parser};
#[clap(group(
ArgGroup::new("vers")
.required(true)
.args(&["set_ver", "major", "minor", "patch"]),
.args(["set_ver", "major", "minor", "patch"]),
))]
struct Cli {
/// set version manually
Expand Down

0 comments on commit f84e38a

Please sign in to comment.