pub struct Locale { /* private fields */ }Expand description
A language tag as the host reports it — "en", "en-US",
"zh-Hans-CN". Carried inline rather than as a String so Env
stays Copy: a view reads ui.env() every frame, and a tag that
allocated would allocate on every one of them.
The core does not parse it. It is passed through to the view, which hands it to whatever formats dates and numbers — kui has no opinion about what is a language and what is a region.
Implementations§
Source§impl Locale
impl Locale
Sourcepub const CAP: usize = 31
pub const CAP: usize = 31
Longest tag that fits. RFC 5646 allows longer in principle; 31
holds every tag anyone ships, including the script-and-region ones
(zh-Hant-HK) and a private-use suffix.
Sourcepub fn new(tag: &str) -> Option<Self>
pub fn new(tag: &str) -> Option<Self>
None for a tag that is empty, longer than Locale::CAP, or not
ASCII — the three things a well-formed language tag is not. A host
that hands one of those over reads back “the host cannot tell”,
which is true: what it said was not a tag.
pub fn as_str(&self) -> &str
Trait Implementations§
impl Copy for Locale
impl Eq 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
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> 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
key and return true if they are equal.