numsep

Crates.ionumsep
lib.rsnumsep
version0.1.12
sourcesrc
created_at2022-01-06 22:07:42.4856
updated_at2022-01-07 07:47:02.241192
descriptionAdding thousands-seperators to numbers
homepage
repositoryhttps://github.com/floscodes/rust-numsep
max_upload_size
id509178
size6,736
flopetautschnig (floscodes)

documentation

README

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)));
Commit count: 7

cargo fmt