4 stable releases

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

#2544 in Parser implementations

Download history 824/week @ 2024-07-21 748/week @ 2024-07-28 916/week @ 2024-08-04 893/week @ 2024-08-11 846/week @ 2024-08-18 907/week @ 2024-08-25 945/week @ 2024-09-01 990/week @ 2024-09-08 768/week @ 2024-09-15 693/week @ 2024-09-22 1183/week @ 2024-09-29 1056/week @ 2024-10-06 1099/week @ 2024-10-13 1039/week @ 2024-10-20 1029/week @ 2024-10-27 1013/week @ 2024-11-03

4,278 downloads per month
Used in 14 crates (13 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");

lib.rs:

Format a file size 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