pub enum Locale {
Ca,
De,
Fr,
Gb,
It,
Us,
}Expand description
A locale the pattern catalogue carries locale-specific detectors for.
Parse a user-supplied tag with str::parse or
Locale::parse_optional; the variants are also usable directly
(Locale::It).
Variants§
Implementations§
Source§impl Locale
impl Locale
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
The ISO 3166-1 alpha-2 code, as the pattern catalogue spells it.
Sourcepub fn parse_optional(tag: Option<&str>) -> Result<Option<Self>, String>
pub fn parse_optional(tag: Option<&str>) -> Result<Option<Self>, String>
Parse an optional tag, where absent and blank both mean “no locale”.
This is the boundary helper for callers who receive a tag from a user or
another language: None and "" are the same request (rank patterns
without a locale preference), and every other value must resolve.
use dataprof_core::Locale;
assert_eq!(Locale::parse_optional(None), Ok(None));
assert_eq!(Locale::parse_optional(Some(" ")), Ok(None));
assert_eq!(Locale::parse_optional(Some("it-IT")), Ok(Some(Locale::It)));
assert!(Locale::parse_optional(Some("XX")).is_err());Trait Implementations§
impl Copy for Locale
impl Eq for Locale
Source§impl Ord for Locale
impl Ord for Locale
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Locale
impl PartialOrd for Locale
impl StructuralPartialEq for Locale
Auto Trait Implementations§
impl Freeze for Locale
impl RefUnwindSafe for Locale
impl Send for Locale
impl Sync for Locale
impl Unpin for Locale
impl UnsafeUnpin for Locale
impl UnwindSafe for Locale
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.