pub trait ToFormat {
// Required method
fn to_format(
self,
format: &str,
culture: Culture,
) -> Result<String, ConversionError>;
}
Expand description
Trait to display a number with ‘to_format’ function The format parameter is like C# toString() function with N0 / N2 / N4 values N0 display 0 digit, N2 two digit, N4 four digit etc. The max is N9 digit And the culture parameter is use to display with the selected culture (it automatically apply the thousand and decimal separator of the given culture)
§Example
use num_string::{Culture, ToFormat};
assert_eq!(1000.to_format("N0", Culture::English).unwrap(), "1,000");
assert_eq!(1000.to_format("N2", Culture::French).unwrap(), "1 000,00");