Skip to main content

LocaleFormatters

Struct LocaleFormatters 

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

Reusable ICU4X formatters bound to one explicit locale.

Construct this type when the selected formatting locale changes, then reuse it for display values. The locale controls language, calendar conventions, numbering system, separators, date order, and currency placement. Formatting only changes presentation; it never changes stored dates, currency codes, or monetary values.

Implementations§

Source§

impl LocaleFormatters

Source

pub fn new(locale: &Locale) -> Result<LocaleFormatters, FormatError>

Creates reusable formatters for the selected locale.

Source

pub fn format_year_month( &self, year: i32, month: u8, ) -> Result<String, FormatError>

Formats a Gregorian year and month with localized month names and ordering.

Source

pub fn format_date( &self, year: i32, month: u8, day: u8, ) -> Result<String, FormatError>

Formats a Gregorian date using the locale’s date order and conventions.

Source

pub fn format_decimal( &self, value: f64, fraction_digits: u8, ) -> Result<String, FormatError>

Formats a decimal with locale-specific digits and separators at fixed precision.

fraction_digits may range from zero through eighteen.

Source

pub fn format_percent( &self, ratio: f64, fraction_digits: u8, ) -> Result<String, FormatError>

Formats a ratio as a localized percentage; for example, 0.125 represents 12.5%.

fraction_digits may range from zero through eighteen.

Source

pub fn format_currency( &self, amount: f64, currency_code: &str, ) -> Result<String, FormatError>

Formats a monetary amount in the locale using an uppercase ISO 4217 code.

This method applies currency-specific display precision and placement. It does not convert the amount or alter its currency.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
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.