[go: up one dir, main page]

separator 0.4.1

Formats numbers into strings with thousands separators for readability.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[macro_use] extern crate separator;
use separator::Separatable;

struct CustomNum(u32);

impl Separatable for CustomNum {
    fn separated_string(&self) -> String {
        let string = format!("{}", self.0);
        separated_uint!(string)
    }
}

#[test]
fn nine_hundred_million() {
    let i = CustomNum(900000000);
    assert_eq!("900,000,000", &i.separated_string());
}