fmt_comma 0.1.4

Format Comma library
Documentation
  • Coverage
  • 20%
    1 out of 5 items documented1 out of 4 items with examples
  • Size
  • Source code size: 7.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 47.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • takeweb/fmt_comma
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • takeweb

Format Comma library

  • Add Comma
  • Add Comma for decimal
  • Remove Comma
  • Remove Comma for decimal

Installation

cargo add fmt_comma

Example(Add comma)

use fmt_comma::format;

fn main() {
    let pc_price: f32 = 9800000.0;
    let company_a_send_cost: f32 = 1200.0;
    let company_a_pc_price = pc_price * 0.8 + company_a_send_cost;
    let company_b_pc_price = pc_price * 0.9;
    println!("Company A:{}yen", format(company_a_pc_price as isize));    // → 7,841,200yen
    println!("Company B:{}yen", format(company_b_pc_price as isize));    // → 8,820,000yen
}

Example(Add comma for decimal)

use fmt_comma::format_decimal;

fn main() {
    println!("Company C:{}yen", format_decimal(10003.333));  // → 10,003.333yen
    println!("Company D:{}yen", format_decimal(3380.2));     // → 3,380.2yen
    println!("Company E:{}yen", format_decimal(3380.0));     // → 3,380yen
}

Example(Remove comma)

use fmt_comma::rm_comma;

fn main() {
    println!("Company F:{}yen", rm_comma("10,003"));               // → 10003yen
}

Example(Remove comma for decimal)

use fmt_comma::rm_comma_decimal;

fn main() {
    println!("Company G:{}yen", rm_comma_decimal("10,003.333"));   // → 10003.333yen
}