forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: Require/default conditional APIs are more explicit
This helps with - API cleanup by not having ambigious `None`, see clap-rs#950 - Removes ambiguity with `None` when using owned/borrowed types for clap-rs#1041
- Loading branch information
Showing
8 changed files
with
105 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
use crate::OsStr; | ||
|
||
/// Operations to perform on argument values | ||
/// | ||
/// These do not apply to [`ValueSource::DefaultValue`][crate::parser::ValueSource::DefaultValue] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub(crate) enum ArgPredicate { | ||
pub enum ArgPredicate { | ||
/// Is the argument present? | ||
IsPresent, | ||
/// Does the argument match the specified value? | ||
Equals(OsStr), | ||
} | ||
|
||
impl<'help> From<Option<&'help std::ffi::OsStr>> for ArgPredicate { | ||
fn from(other: Option<&'help std::ffi::OsStr>) -> Self { | ||
match other { | ||
Some(other) => Self::Equals(other.to_owned().into()), | ||
None => Self::IsPresent, | ||
} | ||
impl<S: Into<OsStr>> From<S> for ArgPredicate { | ||
fn from(other: S) -> Self { | ||
Self::Equals(other.into()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.