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
impl LocaleFormatters
Sourcepub fn new(locale: &Locale) -> Result<LocaleFormatters, FormatError>
pub fn new(locale: &Locale) -> Result<LocaleFormatters, FormatError>
Creates reusable formatters for the selected locale.
Sourcepub fn format_year_month(
&self,
year: i32,
month: u8,
) -> Result<String, FormatError>
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.
Sourcepub fn format_date(
&self,
year: i32,
month: u8,
day: u8,
) -> Result<String, FormatError>
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.
Sourcepub fn format_decimal(
&self,
value: f64,
fraction_digits: u8,
) -> Result<String, FormatError>
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.
Sourcepub fn format_percent(
&self,
ratio: f64,
fraction_digits: u8,
) -> Result<String, FormatError>
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.
Sourcepub fn format_currency(
&self,
amount: f64,
currency_code: &str,
) -> Result<String, FormatError>
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§
impl !Freeze for LocaleFormatters
impl !Send for LocaleFormatters
impl !Sync for LocaleFormatters
impl RefUnwindSafe for LocaleFormatters
impl Unpin for LocaleFormatters
impl UnsafeUnpin for LocaleFormatters
impl UnwindSafe for LocaleFormatters
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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