Struct icu_capi::locale_core::ffi::Locale
source · pub struct Locale(pub Locale);
Expand description
An ICU4X Locale, capable of representing strings like "en-US"
.
Tuple Fields§
§0: Locale
Implementations§
source§impl Locale
impl Locale
sourcepub fn from_string(name: &DiplomatStr) -> Result<Box<Locale>, LocaleParseError>
pub fn from_string(name: &DiplomatStr) -> Result<Box<Locale>, LocaleParseError>
Construct an Locale
from an locale identifier.
This will run the complete locale parsing algorithm. If code size and
performance are critical and the locale is of a known shape (such as
aa-BB
) use create_und
, set_language
, set_script
, and set_region
.
sourcepub fn basename(&self, write: &mut DiplomatWrite)
pub fn basename(&self, write: &mut DiplomatWrite)
Returns a string representation of the LanguageIdentifier
part of
Locale
.
sourcepub fn get_unicode_extension(
&self,
s: &DiplomatStr,
write: &mut DiplomatWrite,
) -> Option<()>
pub fn get_unicode_extension( &self, s: &DiplomatStr, write: &mut DiplomatWrite, ) -> Option<()>
Returns a string representation of the unicode extension.
sourcepub fn language(&self, write: &mut DiplomatWrite)
pub fn language(&self, write: &mut DiplomatWrite)
Returns a string representation of Locale
language.
sourcepub fn set_language(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
pub fn set_language(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
Set the language part of the Locale
.
sourcepub fn region(&self, write: &mut DiplomatWrite) -> Option<()>
pub fn region(&self, write: &mut DiplomatWrite) -> Option<()>
Returns a string representation of Locale
region.
sourcepub fn set_region(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
pub fn set_region(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
Set the region part of the Locale
.
sourcepub fn script(&self, write: &mut DiplomatWrite) -> Option<()>
pub fn script(&self, write: &mut DiplomatWrite) -> Option<()>
Returns a string representation of Locale
script.
sourcepub fn set_script(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
pub fn set_script(&mut self, s: &DiplomatStr) -> Result<(), LocaleParseError>
Set the script part of the Locale
. Pass an empty string to remove the script.
sourcepub fn normalize(
s: &DiplomatStr,
write: &mut DiplomatWrite,
) -> Result<(), LocaleParseError>
pub fn normalize( s: &DiplomatStr, write: &mut DiplomatWrite, ) -> Result<(), LocaleParseError>
Normalizes a locale string.
pub fn normalizing_eq(&self, other: &DiplomatStr) -> bool
pub fn compare_to_string(&self, other: &DiplomatStr) -> Ordering
pub fn compare_to(&self, other: &Self) -> Ordering
source§impl Locale
impl Locale
pub fn to_datalocale(&self) -> DataLocale
Trait Implementations§
source§impl<'a> From<&'a Locale> for SentenceBreakOptions<'a>
impl<'a> From<&'a Locale> for SentenceBreakOptions<'a>
Auto Trait Implementations§
impl Freeze for Locale
impl RefUnwindSafe for Locale
impl Send for Locale
impl Sync for Locale
impl Unpin 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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more