format_money 0.1.1

A simple function that takes a string reference &str and returns a String with money format $ #'###,###.##
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 5.42 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • FenixAlive/format_money
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FenixAlive

format_money

format_money is a simple function that takes a string reference &str as a number, evaluates it and returns a String with money format $ #'###,###.##

Examples:

use format_money::format_money;

fn main() {
    println!("{}",format_money("0100010"));
    //it prints $ 100,010.00

   assert_eq!(format_money("."), "$ 0.00");

   assert_eq!(format_money("000.157"), "$ 0.15");

   assert_eq!(format_money("103"), "$ 103.00");

   assert_eq!(format_money("001000000334533461000813.5792"), "$ 1,000'000,334'533,461'000,813.57");

   assert_eq!(format_money("0000.00"), "$ 0.00");

   assert_eq!(format_money("00000010.00000"), "$ 10.00");

   assert_eq!(format_money("0100.00000"), "$ 100.00");

   assert_eq!(format_money("F1c0.0A000"), "$ 0.00");
}