4 stable releases

1.0.3 Sep 30, 2020
1.0.2 Aug 23, 2020
1.0.0 Aug 22, 2020

#2405 in Text processing

Download history 2819/week @ 2025-12-14 2612/week @ 2025-12-21 2409/week @ 2025-12-28 2730/week @ 2026-01-04 3497/week @ 2026-01-11 3047/week @ 2026-01-18 2510/week @ 2026-01-25 2885/week @ 2026-02-01 2813/week @ 2026-02-08 3087/week @ 2026-02-15 3423/week @ 2026-02-22 3110/week @ 2026-03-01 2843/week @ 2026-03-08 3022/week @ 2026-03-15 3072/week @ 2026-03-22 2786/week @ 2026-03-29

12,153 downloads per month
Used in 13 crates (11 directly)

MIT license

5KB
72 lines

A small function formatting a file size into the nearest ISO representation fitting into 4 characters.

Examples:

use file_size::fit_4;

assert_eq!(&fit_4(999), "999");
assert_eq!(&fit_4(12345), "12K");
assert_eq!(&fit_4(999_999), "1.0M");
assert_eq!(&fit_4(7_155_456_789_012), "7.2T");

No runtime deps