Expand description
Tiny, zero-dependency helpers to turn machine values into human-readable strings.
All functions use only the standard library and never panic on valid input.
§Examples
use humanize_values::{format_bytes, format_duration, ordinal, pluralize};
assert_eq!(format_bytes(1536), "1.5 KB");
assert_eq!(format_duration(3661), "1h 1m 1s");
assert_eq!(ordinal(21), "21st");
assert_eq!(pluralize(3, "file", "files"), "3 files");Functions§
- format_
bytes - Formats a byte count as a human-readable string using binary (1024-based) units.
- format_
duration - Formats a duration given in seconds as a compact
d/h/m/sstring. - ordinal
- Adds an English ordinal suffix to an integer.
- pluralize
- Returns
"<count> <word>", choosing the singular or plural form based oncount.