Skip to content

Commit

Permalink
refactor(parser): Centralize knowledge for explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Oct 12, 2022
1 parent e704adb commit e98fc7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/matches/matched_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions src/parser/matches/value_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit e98fc7f

Please sign in to comment.