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 ).
45//! Custom error type(s) for the parent module.
67use displaydoc::Display;
89/// A custom error type for [`CodePointTrie`](super::CodePointTrie).
10#[derive(#[automatically_derived]
impl ::core::marker::Copy for Error { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Error {
#[inline]
fn clone(&self) -> Error {
let _: ::core::clone::AssertParamIsClone<&'static str>;
*self
}
}Clone, #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () =
{
impl ::core::fmt::Display for Error {
fn fmt(&self, formatter: &mut ::core::fmt::Formatter)
-> ::core::fmt::Result {
#[allow(unused_variables)]
match self {
Self::FromDeserialized { reason } => {
formatter.write_fmt(format_args!("Could not construct CodePointTrie from deserialized values: {0}",
reason))
}
Self::EmptyDataVector => {
formatter.write_fmt(format_args!("CodePointTrie must be constructed from data vector with at least one element"))
}
Self::IndexTooShortForFastAccess => {
formatter.write_fmt(format_args!("CodePointTrie must be constructed from index vector long enough to accommodate fast-path access"))
}
Self::DataTooShortForFastAccess => {
formatter.write_fmt(format_args!("CodePointTrie must be constructed from data vector long enough to accommodate fast-path access"))
}
}
}
}
};Display, #[automatically_derived]
impl ::core::fmt::Debug for Error {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Error::FromDeserialized { reason: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"FromDeserialized", "reason", &__self_0),
Error::EmptyDataVector =>
::core::fmt::Formatter::write_str(f, "EmptyDataVector"),
Error::IndexTooShortForFastAccess =>
::core::fmt::Formatter::write_str(f,
"IndexTooShortForFastAccess"),
Error::DataTooShortForFastAccess =>
::core::fmt::Formatter::write_str(f,
"DataTooShortForFastAccess"),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Error {
#[inline]
fn eq(&self, other: &Error) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Error::FromDeserialized { reason: __self_0 },
Error::FromDeserialized { reason: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq)]
11#[non_exhaustive]
12pub enum Error {
13/// Could not construct [`CodePointTrie`](super::CodePointTrie) from deserialized values
14#[displaydoc("Could not construct CodePointTrie from deserialized values: {reason}")]
15FromDeserialized {
16/// Reason for inability to deserialize values.
17reason: &'static str,
18 },
19/// [`CodePointTrie`](super::CodePointTrie) must be constructed from data vector with at least one element
20#[displaydoc("CodePointTrie must be constructed from data vector with at least one element")]
21EmptyDataVector,
22/// [`CodePointTrie`](super::CodePointTrie) must be constructed from index vector long enough to accommodate fast-path access
23#[displaydoc("CodePointTrie must be constructed from index vector long enough to accommodate fast-path access")]
24IndexTooShortForFastAccess,
25/// [`CodePointTrie`](super::CodePointTrie) must be constructed from data vector long enough to accommodate fast-path access
26#[displaydoc("CodePointTrie must be constructed from data vector long enough to accommodate fast-path access")]
27DataTooShortForFastAccess,
28}
2930impl core::error::Errorfor Error {}