#size #file #utility #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

#1054 in Text processing

Download history 758/week @ 2024-03-13 830/week @ 2024-03-20 818/week @ 2024-03-27 736/week @ 2024-04-03 705/week @ 2024-04-10 622/week @ 2024-04-17 916/week @ 2024-04-24 924/week @ 2024-05-01 772/week @ 2024-05-08 753/week @ 2024-05-15 595/week @ 2024-05-22 840/week @ 2024-05-29 672/week @ 2024-06-05 869/week @ 2024-06-12 832/week @ 2024-06-19 700/week @ 2024-06-26

3,178 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