Expand description
§Adding thousands-seperators to numbers
§First of all add the following
[dependencies]
numsep = "0.1.12"§to your Cargo.toml-File.
§Examples:
use numsep::*;
let number = 10000;
assert_eq!("10,000", separate(n, Locale::English));
§The Locale- enum provides the following country-presets:
Locale::English,
Locale::German,
Locale::Canadian,
Locale::Swiss,
Locale::Swiss2,
Locale::Singapore,§AND a CUSTOM-Scheme…
Locale::Custom(Scheme)§… that can be used like that:
use numsep::*;
let custom = custom()
.set_separator("'")
.set_radix(",");
let n = 2000.5;
assert_eq!("2'000,5", separate(n, Locale::Custom(custom)));Structs§
Enums§
- Locale
- public enum to set the separation-style using the cconcerning language.
There could also be set a custom-style using the functions
custom, [set_separator] and [set_radix]. [set_separator]: struct.Scheme.html#method.set_separator [set_radix]: struct.Scheme.html#method.set_radixcustom: fn.custom.html#
Functions§
- custom
- creates a custom-
Schemethat can be customized with [set_separator] and [set_radix]Scheme: struct.Scheme.html# - separate
- This function adds thousands-separators to the concerning number. It takes the number as the first argument, and the country-style or customized-style as the second argument that’s type is
Locale.