pub struct NumberFormatter { /* private fields */ }Expand description
A locale-aware number formatter.
Implementations§
Source§impl NumberFormatter
impl NumberFormatter
Sourcepub fn for_locale(locale: &str) -> Result<NumberFormatter, FormattingError>
pub fn for_locale(locale: &str) -> Result<NumberFormatter, FormattingError>
Create a formatter for the given locale tag using default decimal options.
§Errors
Returns FormattingError::UnsupportedLocale if the locale is not supported.
Sourcepub fn with_config(
locale: &str,
config: NumberFormat,
) -> Result<NumberFormatter, FormattingError>
pub fn with_config( locale: &str, config: NumberFormat, ) -> Result<NumberFormatter, FormattingError>
Create a formatter with explicit configuration.
§Errors
Returns FormattingError::UnsupportedLocale if the locale is not supported.
Sourcepub fn from_data(
data: &'static LocaleData,
config: NumberFormat,
) -> NumberFormatter
pub fn from_data( data: &'static LocaleData, config: NumberFormat, ) -> NumberFormatter
Create from pinned locale data directly.
Sourcepub fn format_int<I>(&self, value: I) -> String
pub fn format_int<I>(&self, value: I) -> String
Format an integer value according to the locale’s conventions.
Sourcepub fn format_float(&self, value: f64) -> Result<String, FormattingError>
pub fn format_float(&self, value: f64) -> Result<String, FormattingError>
Format a floating-point value according to the locale’s conventions.
§Errors
Returns FormattingError::NonFinite if the value is NaN or infinite and
allow_non_finite is false.
Trait Implementations§
Source§impl Clone for NumberFormatter
impl Clone for NumberFormatter
Source§fn clone(&self) -> NumberFormatter
fn clone(&self) -> NumberFormatter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Forget for NumberFormatter
impl Freeze for NumberFormatter
impl Move for NumberFormatter
impl RefUnwindSafe for NumberFormatter
impl Send for NumberFormatter
impl Sync for NumberFormatter
impl Unpin for NumberFormatter
impl UnsafeUnpin for NumberFormatter
impl UnwindSafe for NumberFormatter
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
Mutably borrows from an owned value. Read more