Skip to main content

clap_builder/builder/
arg_predicate.rs

1use crate::builder::OsStr;
2
3/// Operations to perform on argument values
4///
5/// These do not apply to [`ValueSource::DefaultValue`][crate::parser::ValueSource::DefaultValue]
6#[derive(#[automatically_derived]
impl ::core::clone::Clone for ArgPredicate {
    #[inline]
    fn clone(&self) -> ArgPredicate {
        match self {
            ArgPredicate::IsPresent => ArgPredicate::IsPresent,
            ArgPredicate::Equals(__self_0) =>
                ArgPredicate::Equals(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ArgPredicate {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ArgPredicate::IsPresent =>
                ::core::fmt::Formatter::write_str(f, "IsPresent"),
            ArgPredicate::Equals(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Equals",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ArgPredicate {
    #[inline]
    fn eq(&self, other: &ArgPredicate) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ArgPredicate::Equals(__self_0),
                    ArgPredicate::Equals(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ArgPredicate {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<OsStr>;
    }
}Eq)]
7#[cfg_attr(feature = "unstable-v5", non_exhaustive)]
8pub enum ArgPredicate {
9    /// Is the argument present?
10    IsPresent,
11    /// Does the argument match the specified value?
12    Equals(OsStr),
13}
14
15impl<S: Into<OsStr>> From<S> for ArgPredicate {
16    fn from(other: S) -> Self {
17        Self::Equals(other.into())
18    }
19}