From e98fc7f6ebc0cb54a6357bf01d1387a4860f17b6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 12 Oct 2022 07:46:39 -0500 Subject: [PATCH] refactor(parser): Centralize knowledge for explicit --- src/parser/matches/matched_arg.rs | 2 +- src/parser/matches/value_source.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parser/matches/matched_arg.rs b/src/parser/matches/matched_arg.rs index 22d5b414c14..6a80625f856 100644 --- a/src/parser/matches/matched_arg.rs +++ b/src/parser/matches/matched_arg.rs @@ -130,7 +130,7 @@ impl MatchedArg { } pub(crate) fn check_explicit(&self, predicate: &ArgPredicate) -> bool { - if self.source == Some(ValueSource::DefaultValue) { + if self.source.map(|s| !s.is_explicit()).unwrap_or(false) { return false; } diff --git a/src/parser/matches/value_source.rs b/src/parser/matches/value_source.rs index fb762d2af68..db45d9c0fd0 100644 --- a/src/parser/matches/value_source.rs +++ b/src/parser/matches/value_source.rs @@ -9,3 +9,9 @@ pub enum ValueSource { /// Value was passed in on the command-line CommandLine, } + +impl ValueSource { + pub(crate) fn is_explicit(self) -> bool { + self != Self::DefaultValue + } +}