Struct rust_icu_uloc::ULoc[][src]

pub struct ULoc { /* fields omitted */ }
Expand description

A representation of a Unicode locale.

For the time being, only basic conversion and methods are in fact implemented.

To get basic validation when creating a locale, use for_language_tag with a Unicode BCP-47 locale ID.

Implementations

impl ULoc[src]

pub fn language(&self) -> Option<String>[src]

Implements uloc_getLanguage.

pub fn script(&self) -> Option<String>[src]

Implements uloc_getScript.

pub fn country(&self) -> Option<String>[src]

Implements uloc_getCountry.

pub fn variant(&self) -> Option<String>[src]

Implements uloc_getVariant.

pub fn canonicalize(&self) -> Result<ULoc, Error>[src]

Implements uloc_canonicalize from ICU4C.

pub fn add_likely_subtags(&self) -> Result<ULoc, Error>[src]

Implements uloc_addLikelySubtags from ICU4C.

pub fn minimize_subtags(&self) -> Result<ULoc, Error>[src]

Implements uloc_minimizeSubtags from ICU4C.

pub fn to_language_tag(&self, strict: bool) -> Result<String, Error>[src]

Implements uloc_toLanguageTag from ICU4C.

pub fn keywords(&self) -> impl Iterator<Item = String>[src]

Implements uloc_openKeywords() from ICU4C.

pub fn unicode_keywords(&self) -> impl Iterator<Item = String>[src]

Implements icu::Locale::getUnicodeKeywords() from the C++ API.

pub fn keyword_value(&self, keyword: &str) -> Result<Option<String>, Error>[src]

Implements uloc_getKeywordValue() from ICU4C.

pub fn unicode_keyword_value(
    &self,
    unicode_keyword: &str
) -> Result<Option<String>, Error>
[src]

Implements icu::Locale::getUnicodeKeywordValue() from ICU4C.

pub fn label(&self) -> &str[src]

Returns the current label of this locale.

pub fn as_c_str(&self) -> CString[src]

Returns the current locale name as a C string.

pub fn for_language_tag(tag: &str) -> Result<ULoc, Error>[src]

Implements uloc_forLanguageTag from ICU4C.

Note that an invalid tag will cause that tag and all others to be ignored. For example en-us will work but en_US will not.

pub fn base_name(self) -> Self[src]

Implements uloc_getBaseName from ICU4C.

Trait Implementations

impl Clone for ULoc[src]

fn clone(&self) -> ULoc[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for ULoc[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Display for ULoc[src]

Implement the Display trait to convert the ULoc into string for display.

The string for display and string serialization happen to be the same for ULoc.

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<ULoc> for ULocMut[src]

fn from(l: ULoc) -> Self[src]

Turns ULoc into ULocMut, which can be mutated.

impl From<ULocMut> for ULoc[src]

fn from(lm: ULocMut) -> Self[src]

Performs the conversion.

impl Hash for ULoc[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for ULoc[src]

fn cmp(&self, other: &Self) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<ULoc> for ULoc[src]

fn eq(&self, other: &ULoc) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &ULoc) -> bool[src]

This method tests for !=.

impl PartialOrd<ULoc> for ULoc[src]

fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl TryFrom<&'_ CStr> for ULoc[src]

fn try_from(s: &CStr) -> Result<Self, Self::Error>[src]

Creates a new ULoc from a borrowed C string.

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<&'_ str> for ULoc[src]

fn try_from(s: &str) -> Result<Self, Self::Error>[src]

Creates a new ULoc from a string slice.

The creation wil fail if the locale is nonexistent.

type Error = Error

The type returned in the event of a conversion error.

impl Eq for ULoc[src]

impl StructuralEq for ULoc[src]

impl StructuralPartialEq for ULoc[src]

Auto Trait Implementations

impl RefUnwindSafe for ULoc

impl Send for ULoc

impl Sync for ULoc

impl Unpin for ULoc

impl UnwindSafe for ULoc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.