Struct DataLocale
struct DataLocale { ... }
A locale type optimized for use in fallbacking and the ICU4X data pipeline.
DataLocale contains less functionality than [Locale] but more than
LanguageIdentifier for better size and performance while still meeting
the needs of the ICU4X data pipeline.
You can create a DataLocale from a borrowed [Locale], which is more
efficient than cloning the [Locale], but less efficient than converting an owned
[Locale]:
use locale;
use DataLocale;
let locale1 = locale!;
let data_locale = from;
DataLocale only supports -u-sd keywords, to reflect the current state of CLDR data
lookup and fallback. This may change in the future.
use ;
use DataLocale;
let locale = "hi-IN-t-en-h0-hybrid-u-attr-ca-buddhist-sd-inas"
.
.unwrap;
assert_eq!;
Fields
language: LanguageLanguage subtag
script: Option<Script>Script subtag
region: Option<Region>Region subtag
variant: Option<Variant>Variant subtag
subdivision: Option<Subtag>Subivision (-u-sd-) subtag
Implementations
impl DataLocale
impl DataLocale
fn total_cmp(self: &Self, other: &Self) -> OrderingReturns an ordering suitable for use in
BTreeSet.fn strict_cmp(self: &Self, other: &[u8]) -> OrderingCompare this
DataLocalewith BCP-47 bytes.The return value is equivalent to what would happen if you first converted this
DataLocaleto a BCP-47 string and then performed a byte comparison.This function is case-sensitive and results in a total order, so it is appropriate for binary search. The only argument producing
Ordering::Equalisself.to_string().Examples
use Ordering; use DataLocale; let bcp47_strings: & = &; for ab in bcp47_strings.windowsComparison against invalid strings:
use DataLocale; let invalid_strings: & = &; let data_locale = "ca-ES"..unwrap; for s in invalid_strings.iterfn is_unknown(self: &Self) -> boolReturns whether this
DataLocaleisundin the locale and extensions portion.Examples
use DataLocale; assert!; assert!; assert!;fn into_locale(self: Self) -> LocaleConverts this
DataLocaleinto aLocale.
impl DataLocale
const fn default() -> Selfconstversion ofDefault::default
impl Clone for DataLocale
fn clone(self: &Self) -> DataLocale
impl Copy for DataLocale
impl Debug for DataLocale
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Default for DataLocale
fn default() -> Self
impl Display for DataLocale
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for DataLocale
impl Freeze for DataLocale
impl From for DataLocale
fn from(locale: Locale) -> Self
impl From for DataLocale
fn from(langid: LanguageIdentifier) -> Self
impl From for DataLocale
fn from(locale: &Locale) -> Self
impl From for DataLocale
fn from(langid: &LanguageIdentifier) -> Self
impl Hash for DataLocale
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl PartialEq for DataLocale
fn eq(self: &Self, other: &DataLocale) -> bool
impl RefUnwindSafe for DataLocale
impl Send for DataLocale
impl StructuralPartialEq for DataLocale
impl Sync for DataLocale
impl Unpin for DataLocale
impl UnsafeUnpin for DataLocale
impl UnwindSafe for DataLocale
impl Writeable for DataLocale
fn write_to<W: core::fmt::Write + ?Sized>(self: &Self, sink: &mut W) -> Resultfn writeable_length_hint(self: &Self) -> LengthHint
impl<T> Any for DataLocale
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for DataLocale
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for DataLocale
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for DataLocale
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> ErasedDestructor for DataLocale
impl<T> From for DataLocale
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for DataLocale
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for DataLocale
fn to_string(self: &Self) -> String
impl<T, U> Into for DataLocale
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for DataLocale
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for DataLocale
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>