]>
git.proxmox.com Git - rustc.git/blob - vendor/time/src/error/parse_from_description.rs
1 //! Error parsing an input into a [`Parsed`](crate::parsing::Parsed) struct
7 /// An error that occurred while parsing the input into a [`Parsed`](crate::parsing::Parsed) struct.
9 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10 pub enum ParseFromDescription
{
11 /// A string literal was not what was expected.
14 /// A dynamic component was not valid.
15 InvalidComponent(&'
static str),
18 impl fmt
::Display
for ParseFromDescription
{
19 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
21 Self::InvalidLiteral
=> f
.write_str("a character literal was not valid"),
22 Self::InvalidComponent(name
) => {
23 write
!(f
, "the '{name}' component could not be parsed")
29 #[cfg(feature = "std")]
30 impl std
::error
::Error
for ParseFromDescription {}
32 impl From
<ParseFromDescription
> for crate::Error
{
33 fn from(original
: ParseFromDescription
) -> Self {
34 Self::ParseFromDescription(original
)
38 impl TryFrom
<crate::Error
> for ParseFromDescription
{
39 type Error
= error
::DifferentVariant
;
41 fn try_from(err
: crate::Error
) -> Result
<Self, Self::Error
> {
43 crate::Error
::ParseFromDescription(err
) => Ok(err
),
44 _
=> Err(error
::DifferentVariant
),