Trait digit_group::FormatGroup
[−]
[src]
pub trait FormatGroup { fn format_si(&self, decimal_mark: char) -> String; fn format_commas(&self) -> String; fn format_custom(
&self,
decimal_mark: char,
grouping_delimiter: char,
first_group_size: usize,
group_size: usize,
group_fractional_part: bool
) -> String; }
Various formatters provided for integer grouping.
Required Methods
fn format_si(&self, decimal_mark: char) -> String
Formats the number according to ISO 80000-1, using a custom decimal_mark
.
Example
use digit_group::FormatGroup; let x: f64 = 123456789.01234; assert_eq!(x.format_si('.'), "123 456 789.012 34")
fn format_commas(&self) -> String
Formats the integral value into groups of three, separated by commas.
Example
use digit_group::FormatGroup; let x: u64 = 123456789; assert_eq!(x.format_commas(), "123,456,789")
fn format_custom(
&self,
decimal_mark: char,
grouping_delimiter: char,
first_group_size: usize,
group_size: usize,
group_fractional_part: bool
) -> String
&self,
decimal_mark: char,
grouping_delimiter: char,
first_group_size: usize,
group_size: usize,
group_fractional_part: bool
) -> String
Formats the number based on supplied parameters.
decimal_mark
is the char
used to delimit the integer and fractional portions of the
number.
grouping_delimiter
is the delimiter to use between groups.
first_group_size
is the number of digits of the initial group.
group_size
is the number of digits of subsequent groups.
group_fractional_part
determines whether to apply the above grouping rules to the decimal
portion of the number.
Example
use digit_group::FormatGroup; let x: f64 = 123456789.01; assert_eq!(x.format_custom('#',':',4,2, false), "1:23:45:6789#01")
Implementors
impl FormatGroup for i8
impl FormatGroup for i16
impl FormatGroup for i32
impl FormatGroup for i64
impl FormatGroup for isize
impl FormatGroup for u8
impl FormatGroup for u16
impl FormatGroup for u32
impl FormatGroup for u64
impl FormatGroup for usize
impl FormatGroup for f32
impl FormatGroup for f64