Struct icu::experimental::dimension::units::formatter::UnitsFormatter
source · pub struct UnitsFormatter { /* private fields */ }
Expand description
A formatter for measurement unit values.
UnitsFormatter
supports:
- Rendering in the locale’s units system.
- Locale-sensitive grouping separator positions.
Read more about the options in the super::options
module.
Implementations§
source§impl UnitsFormatter
impl UnitsFormatter
sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
prefs: UnitsFormatterPreferences,
unit: &str,
options: UnitsFormatterOptions,
) -> Result<UnitsFormatter, DataError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: UnitsFormatterPreferences, unit: &str, options: UnitsFormatterOptions, ) -> Result<UnitsFormatter, DataError>
A version of [Self :: try_new
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
prefs: UnitsFormatterPreferences,
unit: &str,
options: UnitsFormatterOptions,
) -> Result<UnitsFormatter, DataError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: UnitsFormatterPreferences, unit: &str, options: UnitsFormatterOptions, ) -> Result<UnitsFormatter, DataError>
A version of [Self :: try_new
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub fn try_new(
prefs: UnitsFormatterPreferences,
unit: &str,
options: UnitsFormatterOptions,
) -> Result<UnitsFormatter, DataError>
pub fn try_new( prefs: UnitsFormatterPreferences, unit: &str, options: UnitsFormatterOptions, ) -> Result<UnitsFormatter, DataError>
Creates a new UnitsFormatter
from compiled locale data and an options bag.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_unstable<D>(
provider: &D,
prefs: UnitsFormatterPreferences,
unit: &str,
options: UnitsFormatterOptions,
) -> Result<UnitsFormatter, DataError>
pub fn try_new_unstable<D>( provider: &D, prefs: UnitsFormatterPreferences, unit: &str, options: UnitsFormatterOptions, ) -> Result<UnitsFormatter, DataError>
A version of Self::try_new
that uses custom data provided by a DataProvider
.
⚠️ The bounds on provider may change over time, including in SemVer minor releases.
sourcepub fn format_fixed_decimal<'l>(
&'l self,
value: &'l Signed<UnsignedFixedDecimal>,
) -> FormattedUnit<'l>
pub fn format_fixed_decimal<'l>( &'l self, value: &'l Signed<UnsignedFixedDecimal>, ) -> FormattedUnit<'l>
Formats a SignedFixedDecimal
value for the given unit.
Auto Trait Implementations§
impl Freeze for UnitsFormatter
impl RefUnwindSafe for UnitsFormatter
impl Send for UnitsFormatter
impl Sync for UnitsFormatter
impl Unpin for UnitsFormatter
impl UnwindSafe for UnitsFormatter
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> 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