File: custom.rs

package info (click to toggle)
rust-separator 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 192 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 377 bytes parent folder | download
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());
}