3 releases

0.1.12 Jan 7, 2022
0.1.1 Jan 6, 2022
0.1.0 Jan 6, 2022

#245 in Value formatting

Download history 4/week @ 2024-11-20 3/week @ 2024-11-27 4/week @ 2024-12-04 21/week @ 2024-12-11 1/week @ 2024-12-18 45/week @ 2025-01-22 99/week @ 2025-01-29 68/week @ 2025-02-05 9/week @ 2025-02-12 13/week @ 2025-02-19 12/week @ 2025-02-26

106 downloads per month

MIT/Apache

7KB
76 lines

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)));

lib.rs:

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)));

Dependencies

~6KB