time/error/
conversion_range.rs

1//! Conversion range error
2
3use core::fmt;
4
5use crate::error;
6
7/// An error type indicating that a conversion failed because the target type could not store the
8/// initial value.
9#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ConversionRange {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "ConversionRange")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for ConversionRange {
    #[inline]
    fn clone(&self) -> ConversionRange { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ConversionRange { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for ConversionRange {
    #[inline]
    fn eq(&self, other: &ConversionRange) -> bool { true }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ConversionRange {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) -> () {}
}Eq)]
10pub struct ConversionRange;
11
12impl fmt::Display for ConversionRange {
13    #[inline]
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        f.write_str("Source value is out of range for the target type")
16    }
17}
18
19impl core::error::Error for ConversionRange {}
20
21impl From<ConversionRange> for crate::Error {
22    #[inline]
23    fn from(err: ConversionRange) -> Self {
24        Self::ConversionRange(err)
25    }
26}
27
28impl TryFrom<crate::Error> for ConversionRange {
29    type Error = error::DifferentVariant;
30
31    #[inline]
32    fn try_from(err: crate::Error) -> Result<Self, Self::Error> {
33        match err {
34            crate::Error::ConversionRange(err) => Ok(err),
35            _ => Err(error::DifferentVariant),
36        }
37    }
38}