pub struct Formatter<const N: usize = 0> { /* private fields */ }Expand description
Formatter of numbers for human-readable output.
Implementations§
Source§impl<const N: usize> Formatter<N>
impl<const N: usize> Formatter<N>
Sourcepub const fn custom(ranged_units: &'static [RangedUnit; N]) -> Option<Self>
pub const fn custom(ranged_units: &'static [RangedUnit; N]) -> Option<Self>
Creates a custom formatter with the given ranged units.
§Invariants
- The first
ranged_unit.range_maxis the base, thenthranged_unit.range_maxis thenth power of the firstranged_unit.range_max. ranged_unitsSHOULD NOT be empty.
Sourcepub const unsafe fn custom_unchecked(
ranged_units: &'static [RangedUnit; N],
) -> Self
pub const unsafe fn custom_unchecked( ranged_units: &'static [RangedUnit; N], ) -> Self
Sourcepub const fn with_separator(self, separator: &'static str) -> Self
pub const fn with_separator(self, separator: &'static str) -> Self
Sets the separator between numbers and units.
Sourcepub const fn with_custom_unit(self, custom_unit: &'static str) -> Self
pub const fn with_custom_unit(self, custom_unit: &'static str) -> Self
Set custom unit attached after the abbreviated number’s unit.
Source§impl<const N: usize> Formatter<N>
impl<const N: usize> Formatter<N>
Sourcepub const fn format_uint(&self, target: u128) -> Formatted
pub const fn format_uint(&self, target: u128) -> Formatted
Formats an unsigned integer, with default 2 decimal places.
Sourcepub const fn format_uint_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: u128,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_uint_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: u128, ) -> Formatted<DECIMAL_PLACES>
Formats an unsigned integer, with fixed DECIMAL_PLACES.
Sourcepub const fn format_int(&self, target: i128) -> Formatted
pub const fn format_int(&self, target: i128) -> Formatted
Formats a signed integer, with default 2 decimal places.
Sourcepub const fn format_int_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: i128,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_int_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: i128, ) -> Formatted<DECIMAL_PLACES>
Formats a signed integer, with fixed DECIMAL_PLACES.
Sourcepub const fn format_double(&self, target: f64) -> Formatted
pub const fn format_double(&self, target: f64) -> Formatted
Formats an f64, with default 2 decimal places.
Sourcepub const fn format_double_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: f64,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_double_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: f64, ) -> Formatted<DECIMAL_PLACES>
Formats an f64, with fixed DECIMAL_PLACES.
Source§impl<const N: usize> Formatter<N>
impl<const N: usize> Formatter<N>
Sourcepub const fn format_usize(&self, target: usize) -> Formatted
pub const fn format_usize(&self, target: usize) -> Formatted
Formats usize, with default 2 decimal places.
Sourcepub const fn format_usize_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: usize,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_usize_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: usize, ) -> Formatted<DECIMAL_PLACES>
Formats usize, with fixed DECIMAL_PLACES.
Sourcepub const fn format_u128(&self, target: u128) -> Formatted
pub const fn format_u128(&self, target: u128) -> Formatted
Formats u128, with default 2 decimal places.
Sourcepub const fn format_u128_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: u128,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_u128_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: u128, ) -> Formatted<DECIMAL_PLACES>
Formats u128, with fixed DECIMAL_PLACES.
Sourcepub const fn format_u64(&self, target: u64) -> Formatted
pub const fn format_u64(&self, target: u64) -> Formatted
Formats u64, with default 2 decimal places.
Sourcepub const fn format_u64_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: u64,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_u64_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: u64, ) -> Formatted<DECIMAL_PLACES>
Formats u64, with fixed DECIMAL_PLACES.
Sourcepub const fn format_u32(&self, target: u32) -> Formatted
pub const fn format_u32(&self, target: u32) -> Formatted
Formats u32, with default 2 decimal places.
Sourcepub const fn format_u32_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: u32,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_u32_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: u32, ) -> Formatted<DECIMAL_PLACES>
Formats u32, with fixed DECIMAL_PLACES.
Sourcepub const fn format_u16(&self, target: u16) -> Formatted
pub const fn format_u16(&self, target: u16) -> Formatted
Formats u16, with default 2 decimal places.
Sourcepub const fn format_u16_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: u16,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_u16_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: u16, ) -> Formatted<DECIMAL_PLACES>
Formats u16, with fixed DECIMAL_PLACES.
Sourcepub const fn format_u8(&self, target: u8) -> Formatted
pub const fn format_u8(&self, target: u8) -> Formatted
Formats u8, with default 2 decimal places.
Sourcepub const fn format_u8_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: u8,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_u8_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: u8, ) -> Formatted<DECIMAL_PLACES>
Formats u8, with fixed DECIMAL_PLACES.
Source§impl<const N: usize> Formatter<N>
impl<const N: usize> Formatter<N>
Sourcepub const fn format_isize(&self, target: isize) -> Formatted
pub const fn format_isize(&self, target: isize) -> Formatted
Formats isize, with default 2 decimal places.
Sourcepub const fn format_isize_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: isize,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_isize_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: isize, ) -> Formatted<DECIMAL_PLACES>
Formats isize, with fixed DECIMAL_PLACES.
Sourcepub const fn format_i128(&self, target: i128) -> Formatted
pub const fn format_i128(&self, target: i128) -> Formatted
Formats i128, with default 2 decimal places.
Sourcepub const fn format_i128_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: i128,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_i128_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: i128, ) -> Formatted<DECIMAL_PLACES>
Formats i128, with fixed DECIMAL_PLACES.
Sourcepub const fn format_i64(&self, target: i64) -> Formatted
pub const fn format_i64(&self, target: i64) -> Formatted
Formats i64, with default 2 decimal places.
Sourcepub const fn format_i64_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: i64,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_i64_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: i64, ) -> Formatted<DECIMAL_PLACES>
Formats i64, with fixed DECIMAL_PLACES.
Sourcepub const fn format_i32(&self, target: i32) -> Formatted
pub const fn format_i32(&self, target: i32) -> Formatted
Formats i32, with default 2 decimal places.
Sourcepub const fn format_i32_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: i32,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_i32_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: i32, ) -> Formatted<DECIMAL_PLACES>
Formats i32, with fixed DECIMAL_PLACES.
Sourcepub const fn format_i16(&self, target: i16) -> Formatted
pub const fn format_i16(&self, target: i16) -> Formatted
Formats i16, with default 2 decimal places.
Sourcepub const fn format_i16_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: i16,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_i16_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: i16, ) -> Formatted<DECIMAL_PLACES>
Formats i16, with fixed DECIMAL_PLACES.
Sourcepub const fn format_i8(&self, target: i8) -> Formatted
pub const fn format_i8(&self, target: i8) -> Formatted
Formats i8, with default 2 decimal places.
Sourcepub const fn format_i8_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: i8,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_i8_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: i8, ) -> Formatted<DECIMAL_PLACES>
Formats i8, with fixed DECIMAL_PLACES.
Source§impl<const N: usize> Formatter<N>
impl<const N: usize> Formatter<N>
Sourcepub const fn format_f64(&self, target: f64) -> Formatted
pub const fn format_f64(&self, target: f64) -> Formatted
Formats f64, with default 2 decimal places.
Sourcepub const fn format_f64_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: f64,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_f64_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: f64, ) -> Formatted<DECIMAL_PLACES>
Formats f64, with fixed DECIMAL_PLACES.
Sourcepub const fn format_f32(&self, target: f32) -> Formatted
pub const fn format_f32(&self, target: f32) -> Formatted
Formats f32, with default 2 decimal places.
Sourcepub const fn format_f32_fixed_dp<const DECIMAL_PLACES: usize>(
&self,
target: f32,
) -> Formatted<DECIMAL_PLACES>
pub const fn format_f32_fixed_dp<const DECIMAL_PLACES: usize>( &self, target: f32, ) -> Formatted<DECIMAL_PLACES>
Formats f32, with fixed DECIMAL_PLACES.