pub struct DecimalFormatter { /* private fields */ }Expand description
A formatter for Decimal, rendering decimal digits in an i18n-friendly way.
DecimalFormatter supports:
- Rendering in the local numbering system
 - Locale-sensitive grouping separator positions
 - Locale-sensitive plus and minus signs
 
To get the resolved numbering system, see provider.
See the crate-level documentation for examples.
๐ This item has a stack size of 96 bytes on the stable toolchain at release date.
Implementationsยง
Sourceยงimpl DecimalFormatter
 
impl DecimalFormatter
Sourcepub fn try_new(
    prefs: DecimalFormatterPreferences,
    options: DecimalFormatterOptions,
) -> Result<DecimalFormatter, DataError>
 
pub fn try_new( prefs: DecimalFormatterPreferences, options: DecimalFormatterOptions, ) -> Result<DecimalFormatter, DataError>
Creates a new DecimalFormatter from compiled data and an options bag.
โจ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_with_buffer_provider(
    provider: &(impl BufferProvider + ?Sized),
    prefs: DecimalFormatterPreferences,
    options: DecimalFormatterOptions,
) -> Result<DecimalFormatter, DataError>
 
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: DecimalFormatterPreferences, options: DecimalFormatterOptions, ) -> Result<DecimalFormatter, DataError>
A version of [Self :: try_new] that uses custom data provided by a BufferProvider.
โจ Enabled with the serde feature.
Sourcepub fn try_new_unstable<D>(
    provider: &D,
    prefs: DecimalFormatterPreferences,
    options: DecimalFormatterOptions,
) -> Result<DecimalFormatter, DataError>
 
pub fn try_new_unstable<D>( provider: &D, prefs: DecimalFormatterPreferences, options: DecimalFormatterOptions, ) -> Result<DecimalFormatter, DataError>
A version of Self::try_new that uses custom data provided by a DataProvider.
๐ Help choosing a constructor
โ ๏ธ The bounds on provider may change over time, including in SemVer minor releases.
Sourcepub fn format<'l>(
    &'l self,
    value: &'l Signed<UnsignedDecimal>,
) -> FormattedDecimal<'l>
 
pub fn format<'l>( &'l self, value: &'l Signed<UnsignedDecimal>, ) -> FormattedDecimal<'l>
Formats a Decimal, returning a FormattedDecimal.
Sourcepub fn format_to_string(&self, value: &Signed<UnsignedDecimal>) -> String
 
pub fn format_to_string(&self, value: &Signed<UnsignedDecimal>) -> String
Formats a Decimal, returning a [String].
Trait Implementationsยง
Sourceยงimpl AsRef<DecimalFormatter> for DecimalFormatter
 
impl AsRef<DecimalFormatter> for DecimalFormatter
Sourceยงfn as_ref(&self) -> &DecimalFormatter
 
fn as_ref(&self) -> &DecimalFormatter
Converts this type into a shared reference of the (usually inferred) input type.
Sourceยงimpl Clone for DecimalFormatter
 
impl Clone for DecimalFormatter
Sourceยงfn clone(&self) -> DecimalFormatter
 
fn clone(&self) -> DecimalFormatter
Returns a copy of the value. Read more
1.0.0 ยท 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 Freeze for DecimalFormatter
impl RefUnwindSafe for DecimalFormatter
impl !Send for DecimalFormatter
impl !Sync for DecimalFormatter
impl Unpin for DecimalFormatter
impl UnwindSafe for DecimalFormatter
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
Sourceยงimpl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
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>
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 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>
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