summaryrefslogtreecommitdiffstats
path: root/vendor/clap_builder/src/parser/parser.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/clap_builder/src/parser/parser.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_builder/src/parser/parser.rs')
-rw-r--r--vendor/clap_builder/src/parser/parser.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/vendor/clap_builder/src/parser/parser.rs b/vendor/clap_builder/src/parser/parser.rs
index c29100485..723e1cd69 100644
--- a/vendor/clap_builder/src/parser/parser.rs
+++ b/vendor/clap_builder/src/parser/parser.rs
@@ -13,9 +13,9 @@ use crate::error::Result as ClapResult;
use crate::mkeymap::KeyType;
use crate::output::Usage;
use crate::parser::features::suggestions;
-use crate::parser::AnyValue;
use crate::parser::{ArgMatcher, SubCommand};
use crate::parser::{Validator, ValueSource};
+use crate::util::AnyValue;
use crate::util::Id;
use crate::ArgAction;
use crate::INTERNAL_ERROR_MSG;
@@ -305,7 +305,8 @@ impl<'cmd> Parser<'cmd> {
.cmd
.get_positionals()
.last()
- .map_or(false, |p_name| !p_name.is_last_set());
+ .map(|p_name| !p_name.is_last_set())
+ .unwrap_or_default();
let missing_pos = self.cmd.is_allow_missing_positional_set()
&& is_second_to_last
@@ -779,9 +780,10 @@ impl<'cmd> Parser<'cmd> {
matcher.check_explicit(arg_id, &crate::builder::ArgPredicate::IsPresent)
})
.filter(|&n| {
- self.cmd.find(n).map_or(true, |a| {
- !(a.is_hide_set() || required.contains(a.get_id()))
- })
+ self.cmd
+ .find(n)
+ .map(|a| !(a.is_hide_set() || required.contains(a.get_id())))
+ .unwrap_or(true)
})
.cloned()
.collect();
@@ -810,9 +812,8 @@ impl<'cmd> Parser<'cmd> {
.cmd
.get_keymap()
.get(&pos_counter)
- .map_or(false, |arg| {
- arg.is_allow_hyphen_values_set() && !arg.is_last_set()
- })
+ .map(|arg| arg.is_allow_hyphen_values_set() && !arg.is_last_set())
+ .unwrap_or_default()
{
debug!(
"Parser::parse_long_args: positional at {} allows hyphens",
@@ -847,7 +848,8 @@ impl<'cmd> Parser<'cmd> {
.cmd
.get_keymap()
.get(&pos_counter)
- .map_or(false, |arg| arg.is_allow_negative_numbers_set())
+ .map(|arg| arg.is_allow_negative_numbers_set())
+ .unwrap_or_default()
&& short_arg.is_number()
{
debug!("Parser::parse_short_arg: negative number");
@@ -856,9 +858,8 @@ impl<'cmd> Parser<'cmd> {
.cmd
.get_keymap()
.get(&pos_counter)
- .map_or(false, |arg| {
- arg.is_allow_hyphen_values_set() && !arg.is_last_set()
- })
+ .map(|arg| arg.is_allow_hyphen_values_set() && !arg.is_last_set())
+ .unwrap_or_default()
&& short_arg
.clone()
.any(|c| !c.map(|c| self.cmd.contains_short(c)).unwrap_or_default())
@@ -1536,7 +1537,7 @@ impl<'cmd> Parser<'cmd> {
.filter(|arg_id| {
matcher.check_explicit(arg_id, &crate::builder::ArgPredicate::IsPresent)
})
- .filter(|n| self.cmd.find(n).map_or(true, |a| !a.is_hide_set()))
+ .filter(|n| self.cmd.find(n).map(|a| !a.is_hide_set()).unwrap_or(true))
.cloned()
.collect();