1use core::convert::Infallible;
4use core::fmt;
5
6use crate::error::{self, ParseFromDescription, TryFromParsed};
7
8#[non_exhaustive]
10#[allow(variant_size_differences, reason = "only triggers on some platforms")]
11#[derive(#[automatically_derived]
#[allow(variant_size_differences, reason = "only triggers on some platforms")]
impl ::core::fmt::Debug for Parse {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Parse::TryFromParsed(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TryFromParsed", &__self_0),
Parse::ParseFromDescription(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ParseFromDescription", &__self_0),
Parse::UnexpectedTrailingCharacters { never: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"UnexpectedTrailingCharacters", "never", &__self_0),
}
}
}Debug, #[automatically_derived]
#[allow(variant_size_differences, reason = "only triggers on some platforms")]
impl ::core::clone::Clone for Parse {
#[inline]
fn clone(&self) -> Parse {
let _: ::core::clone::AssertParamIsClone<TryFromParsed>;
let _: ::core::clone::AssertParamIsClone<ParseFromDescription>;
let _: ::core::clone::AssertParamIsClone<Infallible>;
*self
}
}Clone, #[automatically_derived]
#[allow(variant_size_differences, reason = "only triggers on some platforms")]
impl ::core::marker::Copy for Parse { }Copy, #[automatically_derived]
#[allow(variant_size_differences, reason = "only triggers on some platforms")]
impl ::core::cmp::PartialEq for Parse {
#[inline]
fn eq(&self, other: &Parse) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Parse::TryFromParsed(__self_0),
Parse::TryFromParsed(__arg1_0)) => __self_0 == __arg1_0,
(Parse::ParseFromDescription(__self_0),
Parse::ParseFromDescription(__arg1_0)) =>
__self_0 == __arg1_0,
(Parse::UnexpectedTrailingCharacters { never: __self_0 },
Parse::UnexpectedTrailingCharacters { never: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
#[allow(variant_size_differences, reason = "only triggers on some platforms")]
impl ::core::cmp::Eq for Parse {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<TryFromParsed>;
let _: ::core::cmp::AssertParamIsEq<ParseFromDescription>;
let _: ::core::cmp::AssertParamIsEq<Infallible>;
}
}Eq)]
12pub enum Parse {
13 #[expect(missing_docs)]
14 TryFromParsed(TryFromParsed),
15 #[expect(missing_docs)]
16 ParseFromDescription(ParseFromDescription),
17 #[expect(missing_docs)]
18 #[non_exhaustive]
19 #[deprecated(
20 since = "0.3.28",
21 note = "no longer output. moved to the `ParseFromDescription` variant"
22 )]
23 UnexpectedTrailingCharacters {
24 #[doc(hidden)]
25 never: Infallible,
26 },
27}
28
29impl fmt::Display for Parse {
30 #[inline]
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 match self {
33 Self::TryFromParsed(err) => err.fmt(f),
34 Self::ParseFromDescription(err) => err.fmt(f),
35 #[allow(deprecated)]
36 Self::UnexpectedTrailingCharacters { never } => match *never {},
37 }
38 }
39}
40
41impl core::error::Error for Parse {
42 #[inline]
43 fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
44 match self {
45 Self::TryFromParsed(err) => Some(err),
46 Self::ParseFromDescription(err) => Some(err),
47 #[allow(deprecated)]
48 Self::UnexpectedTrailingCharacters { never } => match *never {},
49 }
50 }
51}
52
53impl From<TryFromParsed> for Parse {
54 #[inline]
55 fn from(err: TryFromParsed) -> Self {
56 Self::TryFromParsed(err)
57 }
58}
59
60impl TryFrom<Parse> for TryFromParsed {
61 type Error = error::DifferentVariant;
62
63 #[inline]
64 fn try_from(err: Parse) -> Result<Self, Self::Error> {
65 match err {
66 Parse::TryFromParsed(err) => Ok(err),
67 _ => Err(error::DifferentVariant),
68 }
69 }
70}
71
72impl From<ParseFromDescription> for Parse {
73 #[inline]
74 fn from(err: ParseFromDescription) -> Self {
75 Self::ParseFromDescription(err)
76 }
77}
78
79impl TryFrom<Parse> for ParseFromDescription {
80 type Error = error::DifferentVariant;
81
82 #[inline]
83 fn try_from(err: Parse) -> Result<Self, Self::Error> {
84 match err {
85 Parse::ParseFromDescription(err) => Ok(err),
86 _ => Err(error::DifferentVariant),
87 }
88 }
89}
90
91impl From<Parse> for crate::Error {
92 #[inline]
93 fn from(err: Parse) -> Self {
94 match err {
95 Parse::TryFromParsed(err) => Self::TryFromParsed(err),
96 Parse::ParseFromDescription(err) => Self::ParseFromDescription(err),
97 #[allow(deprecated)]
98 Parse::UnexpectedTrailingCharacters { never } => match never {},
99 }
100 }
101}
102
103impl TryFrom<crate::Error> for Parse {
104 type Error = error::DifferentVariant;
105
106 #[inline]
107 fn try_from(err: crate::Error) -> Result<Self, Self::Error> {
108 match err {
109 crate::Error::ParseFromDescription(err) => Ok(Self::ParseFromDescription(err)),
110 #[allow(deprecated)]
111 crate::Error::UnexpectedTrailingCharacters { never } => match never {},
112 crate::Error::TryFromParsed(err) => Ok(Self::TryFromParsed(err)),
113 _ => Err(error::DifferentVariant),
114 }
115 }
116}