Crates.io | separator |
lib.rs | separator |
version | 0.4.1 |
source | src |
created_at | 2015-07-30 15:15:25.523027 |
updated_at | 2019-03-29 00:11:19.251093 |
description | Formats numbers into strings with thousands separators for readability. |
homepage | |
repository | https://github.com/saghm/rust-separator |
max_upload_size | |
id | 2714 |
size | 24,789 |
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
).
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());
}