tinystr/
error.rs

1// This file is part of ICU4X. For terms of use, please see the file
2// called LICENSE at the top level of the ICU4X source tree
3// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5use displaydoc::Display;
6
7impl core::error::Error for ParseError {}
8
9#[derive(#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () =
    {
        impl ::core::fmt::Display for ParseError {
            fn fmt(&self, formatter: &mut ::core::fmt::Formatter)
                -> ::core::fmt::Result {

                #[allow(unused_variables)]
                match self {
                    Self::TooLong { max, len } => {
                        formatter.write_fmt(format_args!("found string of larger length {0} when constructing string of length {1}",
                                len, max))
                    }
                    Self::ContainsNull => {
                        formatter.write_fmt(format_args!("tinystr types do not support strings with null bytes"))
                    }
                    Self::NonAscii => {
                        formatter.write_fmt(format_args!("attempted to construct TinyAsciiStr from a non-ASCII string"))
                    }
                }
            }
        }
    };Display, #[automatically_derived]
impl ::core::fmt::Debug for ParseError {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ParseError::TooLong { max: __self_0, len: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "TooLong", "max", __self_0, "len", &__self_1),
            ParseError::ContainsNull =>
                ::core::fmt::Formatter::write_str(f, "ContainsNull"),
            ParseError::NonAscii =>
                ::core::fmt::Formatter::write_str(f, "NonAscii"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ParseError {
    #[inline]
    fn eq(&self, other: &ParseError) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ParseError::TooLong { max: __self_0, len: __self_1 },
                    ParseError::TooLong { max: __arg1_0, len: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ParseError {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) -> () {
        let _: ::core::cmp::AssertParamIsEq<usize>;
    }
}Eq)]
10#[non_exhaustive]
11pub enum ParseError {
12    #[displaydoc("found string of larger length {len} when constructing string of length {max}")]
13    TooLong { max: usize, len: usize },
14    #[displaydoc("tinystr types do not support strings with null bytes")]
15    ContainsNull,
16    #[displaydoc("attempted to construct TinyAsciiStr from a non-ASCII string")]
17    NonAscii,
18}