pub struct NumberFormat {
pub min_integer_digits: usize,
pub min_fraction_digits: usize,
pub max_fraction_digits: usize,
pub use_grouping: bool,
pub rounding_mode: RoundingMode,
pub style: NumberStyle,
pub numbering_system: NumberingSystem,
pub allow_non_finite: bool,
}Expand description
Configuration for number formatting.
Fields§
§min_integer_digits: usizeMinimum number of integer digits (left-padded with zeros).
min_fraction_digits: usizeMinimum number of fractional digits (right-padded with zeros).
max_fraction_digits: usizeMaximum number of fractional digits (rounded).
use_grouping: boolWhether thousands / group separators should be inserted.
rounding_mode: RoundingModeRounding mode when truncating fractional digits.
style: NumberStyleDisplay style (Decimal, Percent, Currency).
numbering_system: NumberingSystemNumbering system / digit script.
allow_non_finite: boolWhether non-finite floating point numbers (NaN, Inf) should be formatted
as symbols instead of returning FormattingError::NonFinite.
Implementations§
Source§impl NumberFormat
impl NumberFormat
Sourcepub fn new() -> NumberFormat
pub fn new() -> NumberFormat
Create a new decimal number format configuration with default options.
Sourcepub const fn min_integer_digits(self, digits: usize) -> NumberFormat
pub const fn min_integer_digits(self, digits: usize) -> NumberFormat
Set minimum integer digits.
Sourcepub const fn fraction_digits(self, min: usize, max: usize) -> NumberFormat
pub const fn fraction_digits(self, min: usize, max: usize) -> NumberFormat
Set fraction digit bounds.
Sourcepub const fn use_grouping(self, grouping: bool) -> NumberFormat
pub const fn use_grouping(self, grouping: bool) -> NumberFormat
Set whether grouping separators are used.
Sourcepub const fn rounding_mode(self, mode: RoundingMode) -> NumberFormat
pub const fn rounding_mode(self, mode: RoundingMode) -> NumberFormat
Set the rounding mode.
Sourcepub const fn style(self, style: NumberStyle) -> NumberFormat
pub const fn style(self, style: NumberStyle) -> NumberFormat
Set the number style.
Sourcepub const fn numbering_system(self, system: NumberingSystem) -> NumberFormat
pub const fn numbering_system(self, system: NumberingSystem) -> NumberFormat
Set the numbering system.
Sourcepub const fn allow_non_finite(self, allow: bool) -> NumberFormat
pub const fn allow_non_finite(self, allow: bool) -> NumberFormat
Set whether non-finite numbers (NaN, Inf) format to strings instead of erroring.
Trait Implementations§
Source§impl Clone for NumberFormat
impl Clone for NumberFormat
Source§fn clone(&self) -> NumberFormat
fn clone(&self) -> NumberFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more