1#[derive(#[automatically_derived]
impl ::core::marker::Copy for ContextKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ContextKind {
#[inline]
fn clone(&self) -> ContextKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ContextKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ContextKind::InvalidSubcommand => "InvalidSubcommand",
ContextKind::InvalidArg => "InvalidArg",
ContextKind::PriorArg => "PriorArg",
ContextKind::ValidSubcommand => "ValidSubcommand",
ContextKind::ValidValue => "ValidValue",
ContextKind::InvalidValue => "InvalidValue",
ContextKind::ActualNumValues => "ActualNumValues",
ContextKind::ExpectedNumValues => "ExpectedNumValues",
ContextKind::MinValues => "MinValues",
ContextKind::SuggestedCommand => "SuggestedCommand",
ContextKind::SuggestedSubcommand => "SuggestedSubcommand",
ContextKind::SuggestedArg => "SuggestedArg",
ContextKind::SuggestedValue => "SuggestedValue",
ContextKind::TrailingArg => "TrailingArg",
ContextKind::Suggested => "Suggested",
ContextKind::Usage => "Usage",
ContextKind::Custom => "Custom",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ContextKind {
#[inline]
fn eq(&self, other: &ContextKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ContextKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for ContextKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
3#[non_exhaustive]
4#[cfg(feature = "error-context")]
5pub enum ContextKind {
6 InvalidSubcommand,
8 InvalidArg,
10 PriorArg,
12 ValidSubcommand,
14 ValidValue,
16 InvalidValue,
18 ActualNumValues,
20 ExpectedNumValues,
22 MinValues,
24 SuggestedCommand,
26 SuggestedSubcommand,
28 SuggestedArg,
30 SuggestedValue,
32 TrailingArg,
34 Suggested,
36 Usage,
38 Custom,
40}
41
42impl ContextKind {
43 pub fn as_str(self) -> Option<&'static str> {
45 match self {
46 Self::InvalidSubcommand => Some("Invalid Subcommand"),
47 Self::InvalidArg => Some("Invalid Argument"),
48 Self::PriorArg => Some("Prior Argument"),
49 Self::ValidSubcommand => Some("Valid Subcommand"),
50 Self::ValidValue => Some("Valid Value"),
51 Self::InvalidValue => Some("Invalid Value"),
52 Self::ActualNumValues => Some("Actual Number of Values"),
53 Self::ExpectedNumValues => Some("Expected Number of Values"),
54 Self::MinValues => Some("Minimum Number of Values"),
55 Self::SuggestedCommand => Some("Suggested Command"),
56 Self::SuggestedSubcommand => Some("Suggested Subcommand"),
57 Self::SuggestedArg => Some("Suggested Argument"),
58 Self::SuggestedValue => Some("Suggested Value"),
59 Self::TrailingArg => Some("Trailing Argument"),
60 Self::Suggested => Some("Suggested"),
61 Self::Usage => None,
62 Self::Custom => None,
63 }
64 }
65}
66
67impl std::fmt::Display for ContextKind {
68 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 self.as_str().unwrap_or_default().fmt(f)
70 }
71}
72
73#[derive(#[automatically_derived]
impl ::core::clone::Clone for ContextValue {
#[inline]
fn clone(&self) -> ContextValue {
match self {
ContextValue::None => ContextValue::None,
ContextValue::Bool(__self_0) =>
ContextValue::Bool(::core::clone::Clone::clone(__self_0)),
ContextValue::String(__self_0) =>
ContextValue::String(::core::clone::Clone::clone(__self_0)),
ContextValue::Strings(__self_0) =>
ContextValue::Strings(::core::clone::Clone::clone(__self_0)),
ContextValue::StyledStr(__self_0) =>
ContextValue::StyledStr(::core::clone::Clone::clone(__self_0)),
ContextValue::StyledStrs(__self_0) =>
ContextValue::StyledStrs(::core::clone::Clone::clone(__self_0)),
ContextValue::Number(__self_0) =>
ContextValue::Number(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ContextValue {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ContextValue::None =>
::core::fmt::Formatter::write_str(f, "None"),
ContextValue::Bool(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Bool",
&__self_0),
ContextValue::String(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "String",
&__self_0),
ContextValue::Strings(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Strings", &__self_0),
ContextValue::StyledStr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"StyledStr", &__self_0),
ContextValue::StyledStrs(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"StyledStrs", &__self_0),
ContextValue::Number(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Number",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ContextValue {
#[inline]
fn eq(&self, other: &ContextValue) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(ContextValue::Bool(__self_0), ContextValue::Bool(__arg1_0))
=> __self_0 == __arg1_0,
(ContextValue::String(__self_0),
ContextValue::String(__arg1_0)) => __self_0 == __arg1_0,
(ContextValue::Strings(__self_0),
ContextValue::Strings(__arg1_0)) => __self_0 == __arg1_0,
(ContextValue::StyledStr(__self_0),
ContextValue::StyledStr(__arg1_0)) => __self_0 == __arg1_0,
(ContextValue::StyledStrs(__self_0),
ContextValue::StyledStrs(__arg1_0)) => __self_0 == __arg1_0,
(ContextValue::Number(__self_0),
ContextValue::Number(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ContextValue {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
let _: ::core::cmp::AssertParamIsEq<String>;
let _: ::core::cmp::AssertParamIsEq<Vec<String>>;
let _: ::core::cmp::AssertParamIsEq<crate::builder::StyledStr>;
let _: ::core::cmp::AssertParamIsEq<Vec<crate::builder::StyledStr>>;
let _: ::core::cmp::AssertParamIsEq<isize>;
}
}Eq)]
75#[non_exhaustive]
76#[cfg(feature = "error-context")]
77pub enum ContextValue {
78 None,
80 Bool(bool),
82 String(String),
84 Strings(Vec<String>),
86 StyledStr(crate::builder::StyledStr),
88 StyledStrs(Vec<crate::builder::StyledStr>),
90 Number(isize),
92}
93
94impl std::fmt::Display for ContextValue {
95 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
96 match self {
97 Self::None => "".fmt(f),
98 Self::Bool(v) => v.fmt(f),
99 Self::String(v) => v.fmt(f),
100 Self::Strings(v) => v.join(", ").fmt(f),
101 Self::StyledStr(v) => v.fmt(f),
102 Self::StyledStrs(v) => {
103 for (i, v) in v.iter().enumerate() {
104 if i != 0 {
105 ", ".fmt(f)?;
106 }
107 v.fmt(f)?;
108 }
109 Ok(())
110 }
111 Self::Number(v) => v.fmt(f),
112 }
113 }
114}