Enum icu_locid::ParserError
source · #[non_exhaustive]
pub enum ParserError {
InvalidLanguage,
InvalidSubtag,
InvalidExtension,
DuplicatedExtension,
}
Expand description
List of parser errors that can be generated
while parsing LanguageIdentifier
, Locale
,
subtags
or extensions
.
Re-exported as Error
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
InvalidLanguage
Invalid language subtag.
Examples
use icu::locid::subtags::Language;
use icu::locid::ParserError;
assert_eq!("x2".parse::<Language>(), Err(ParserError::InvalidLanguage));
InvalidSubtag
Invalid script, region or variant subtag.
Examples
use icu::locid::subtags::Region;
use icu::locid::ParserError;
assert_eq!("#@2X".parse::<Region>(), Err(ParserError::InvalidSubtag));
InvalidExtension
Invalid extension subtag.
Examples
use icu::locid::extensions::unicode::Key;
use icu::locid::ParserError;
assert_eq!("#@2X".parse::<Key>(), Err(ParserError::InvalidExtension));
DuplicatedExtension
Duplicated extension.
Examples
use icu::locid::Locale;
use icu::locid::ParserError;
assert_eq!(
"und-u-hc-h12-u-ca-calendar".parse::<Locale>(),
Err(ParserError::DuplicatedExtension)
);
Trait Implementations§
source§impl Clone for ParserError
impl Clone for ParserError
source§fn clone(&self) -> ParserError
fn clone(&self) -> ParserError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ParserError
impl Debug for ParserError
source§impl Display for ParserError
impl Display for ParserError
source§impl Error for ParserError
impl Error for ParserError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl PartialEq<ParserError> for ParserError
impl PartialEq<ParserError> for ParserError
source§fn eq(&self, other: &ParserError) -> bool
fn eq(&self, other: &ParserError) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.