humfmt
Ergonomic human-readable formatting toolkit for Rust
humfmt turns raw machine values into readable text without turning formatting
into a side quest.
It currently includes:
- compact numbers like
15320 -> 15.3K - byte sizes like
1536 -> 1.5KB - ordinals like
21 -> 21st - durations like
3661s -> 1h 1m - relative time like
90s -> 1m 30s ago - natural-language lists like
["red", "green", "blue"] -> "red, green, and blue" - locale-aware output for English, Russian, and Polish
- custom locale overrides for suffixes, separators, ordinals, and duration units
- optional
chronoandtimeintegration no_std-friendly usage withalloc
The goal is still the same: keep the crate small, predictable, and pleasant to reach for.
Quick Example
use Humanize;
Customized Formatting
use Duration;
use ;
List Examples
use ;
let english = list;
assert_eq!;
let plain = list_with;
assert_eq!;
Locale Examples
use Duration;
use ;
let number = number_with;
assert_eq!;
let elapsed = duration_with;
assert_eq!;
let items = list_with;
assert_eq!;
use Duration;
use ;
let number = number_with;
assert_eq!;
assert_eq!;
let relative = ago_with;
assert_eq!;
use ;
let locale = english
.short_suffix
.separators
.duration_unit_fn
.ago_word;
let number = number_with;
assert_eq!;
let relative = ago_with;
assert_eq!;
Current Features
- compact number formatter
- byte-size formatter
- ordinal formatter
- duration formatter
- relative time formatter
- list formatter
- long and short units
- English, Russian, and Polish locale packs
- custom locale builder for suffix and separator overrides
- custom duration-unit, list-style, and relative-time wording hooks
- optional
chronoandtimeintegration - doctests and integration tests
Installation
[]
= "0.2"
For no_std targets with alloc available:
[]
= { = "0.2", = false }
Feature Flags
std(default): enables the standard-library builddefault-features = false: builds the current formatter onno_std+allocenglish: baseline locale included in the default feature setrussian: enables thehumfmt::locale::Russianlocale packpolish: enables thehumfmt::locale::Polishlocale packalloc: reserved compatibility flag in0.2.xchrono: enables adapters forchrono::TimeDeltaandchrono::DateTimetime: enables adapters fortime::Durationandtime::OffsetDateTime
Development Status
humfmt is still early-stage, but the formatter surface is already useful and
deliberate. The direction is to keep the crate focused while expanding locale
coverage and humanizer breadth without turning the API into a maze.
Documentation
- examples:
examples/ - tests:
tests/ - crates.io: humfmt
- docs.rs: humfmt docs
Philosophy
This crate follows one simple rule:
Human formatting should feel stupidly easy.
No giant config ceremony. No formatting gymnastics. No “why is this so annoying?” moments.
Just:
println!;
and move on with your life.
License
MIT.