#utility #file #size #format

file-size

a function formatting file sizes in 4 chars

4 stable releases

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

#388 in Text processing

Download history 402/week @ 2021-10-06 297/week @ 2021-10-13 465/week @ 2021-10-20 527/week @ 2021-10-27 525/week @ 2021-11-03 601/week @ 2021-11-10 336/week @ 2021-11-17 290/week @ 2021-11-24 337/week @ 2021-12-01 260/week @ 2021-12-08 382/week @ 2021-12-15 355/week @ 2021-12-22 382/week @ 2021-12-29 402/week @ 2022-01-05 330/week @ 2022-01-12 363/week @ 2022-01-19

1,518 downloads per month
Used in less than 9 crates

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