5 releases

0.1.4 Dec 14, 2024
0.1.3 Sep 24, 2024
0.1.2 Jul 15, 2024
0.1.1 Jul 15, 2024
0.1.0 Jul 14, 2024

#128 in Value formatting

Download history 62/week @ 2024-12-17 19/week @ 2024-12-24 21/week @ 2024-12-31 26/week @ 2025-01-07 18/week @ 2025-01-14 7/week @ 2025-01-21 34/week @ 2025-02-04 20/week @ 2025-02-11 33/week @ 2025-02-18 21/week @ 2025-02-25 12/week @ 2025-03-04 13/week @ 2025-03-11 10/week @ 2025-03-18 23/week @ 2025-03-25 15/week @ 2025-04-01

63 downloads per month
Used in git-metrics

MIT license

17KB
340 lines

Human Number

This library is just made to format numbers in a pretty human readable way.

Installation

cargo add human-number

Usage

// Using SI scales
let formatter = Formatter::si().with_unit("g");
let result = format!("{}", formatter.format(40_280.0));
assert_eq!(result, "40.28 kg");
let result = format!("{}", formatter.format(0.04823));
assert_eq!(result, "48.23 mg");

// Using binary scales
let formatter = Formatter::binary().with_unit("B");
let result = format!("{}", formatter.format(4096.0));
assert_eq!(result, "4.00 kiB");

No runtime deps