Skip to main content

Locale

Struct Locale 

Source
pub struct Locale { /* private fields */ }
Expand description

the formats of one region (copy it freely)

Implementations§

Source§

impl Locale

Source

pub fn get(tag: &str) -> Locale

the best match of a BCP 47 tag or a POSIX locale name (see the module comment)

Source

pub fn tag(&self) -> &'static str

the tag of the matched data (“de-DE”, “en-001”)

Source

pub fn decimal(&self) -> char

the decimal sign

Source

pub fn group(&self) -> char

the thousands separator

Source

pub fn first_weekday(&self) -> u32

the first day of the week: 0 = Monday .. 6 = Sunday

Source

pub fn rtl(&self) -> bool

right-to-left script (Arabic, Hebrew)

Source

pub fn currency(&self) -> &'static str

the ISO 4217 code of the region’s currency

Source

pub fn month_name(&self, m: u32) -> &'static str

the long (format) name of month m (1..12) in the locale’s language

Source

pub fn fmt_int(&self, n: i64) -> String

an integer with group separators

Source

pub fn fmt_num(&self, v: f64, decimals: u32) -> String

a number with exactly decimals fraction digits (rounded) and group separators

Source

pub fn fmt_percent(&self, fraction: f64, decimals: u32) -> String

a fraction as percent: 0.25 -> “25 %” (de) / “25%” (en)

Source

pub fn fmt_currency(&self, v: f64, code: &str) -> String

an amount of the ISO 4217 currency code (“EUR”, “USD”; unknown codes are shown as is)

Source

pub fn fmt_money(&self, v: f64) -> String

an amount in the region’s own currency

Source

pub fn fmt_size(&self, bytes: u64) -> String

a byte count: “512 B”, “1,5 KB”, “23 MB” (1024 based, one decimal below 10)

Source

pub fn fmt_date(&self, c: &Civil, style: u32) -> String

a date: DATE_SHORT “17.10.2026” / DATE_LONG “17. Oktober 2026”

Source

pub fn fmt_time(&self, c: &Civil) -> String

a time of day: “19:58” / “7:58 PM”

Source

pub fn fmt_date_time(&self, c: &Civil) -> String

the short date and the time: “17.10.2026, 19:58” / “10/17/2026, 7:58 PM”

Source§

impl Locale

Source

pub fn collate(&self, a: &str, b: &str) -> Ordering

compare two texts in the order of the region’s language

Source

pub fn collator(&self) -> Collator

the collator of the region’s language

Trait Implementations§

Source§

impl Clone for Locale

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Locale

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.