digit_group

Crates.iodigit_group
lib.rsdigit_group
version0.1.0
sourcesrc
created_at2017-02-06 12:00:21.64459
updated_at2017-02-06 12:00:21.64459
descriptionProvides grouping (thousands separators) for numeric types.
homepage
repositoryhttps://github.com/jaysonWL/digit_group
max_upload_size
id8410
size24,746
Jayson Lennon (jaysonWL)

documentation

README

digit_group

This is a small Rust crate that provides grouping (aka "thousands separators") for numeric types.

Usage

Cargo.toml:

[dependencies]
digit_group = "0.1"

main.rs:

extern crate digit_group;
use digit_group{FormatGroup,custom_group};

fn main() {
    let x: f64 = 12345678.112233;

    // Typical usage. 
    x.format_commas();                   // 12,345,678.112233
    x.format_si('.');                    // 12 345 678.112 233
    
    // Customizable groupings, decimal marks, and grouping delimiters.
    x.format_custom('#',':',4,2, false); // 12:34:5678#112233
    
    // Customizing precision prior to grouping.
    let y = 5512.332;
    let pre_formatted = format!("{:.4}", x);
    custom_group(&pre_formatted, ',', ' ', 3, 3, false); // 5 512,3320
}
Commit count: 21

cargo fmt