#numbers #comma #num #split #separate #format

separator

Formats numbers into strings with thousands separators for readability

6 releases (3 breaking)

0.4.1 Mar 29, 2019
0.4.0 Nov 24, 2018
0.3.1 Nov 19, 2015
0.3.0 Jul 31, 2015
0.1.0 Jul 30, 2015

#567 in Rust patterns

Download history 21897/week @ 2024-07-29 25703/week @ 2024-08-05 39682/week @ 2024-08-12 27205/week @ 2024-08-19 38394/week @ 2024-08-26 42029/week @ 2024-09-02 37332/week @ 2024-09-09 36932/week @ 2024-09-16 40200/week @ 2024-09-23 44813/week @ 2024-09-30 43910/week @ 2024-10-07 44489/week @ 2024-10-14 49179/week @ 2024-10-21 42856/week @ 2024-10-28 58024/week @ 2024-11-04 47173/week @ 2024-11-11

199,500 downloads per month
Used in 497 crates (30 directly)

MIT license

8KB
183 lines

crates.io Build Status

rust-separator

NOTE: This crate is entirely superseded by the very excellent num-format, which has all the features of separator and much, much more. I highly recommend using num-format instead of this crate.

Formats numbers into strings with thousands separators for readability. It currently supports floating-points (f32 and f64), unsigned integers (u16, u32, u64, u128), signed integers (i16, i32, i64, i128), and size types (isize and usize).

Usage

First, put separator as a dependency in your Cargo.toml as usual:

[dependencies]
separator = "0.3.1"

Then, import the Separatable trait, and call the separated_string on a number:

extern crate separator;

use separator::Separatable;

fn main() {
  let f = -120000000.34345;

  // Prints "-12,000,000.34345"
  println!("{}", f.separated_string());
}

No runtime deps