4 stable releases

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

#1194 in Text processing

Download history 754/week @ 2024-05-27 733/week @ 2024-06-03 758/week @ 2024-06-10 886/week @ 2024-06-17 773/week @ 2024-06-24 674/week @ 2024-07-01 902/week @ 2024-07-08 944/week @ 2024-07-15 784/week @ 2024-07-22 861/week @ 2024-07-29 815/week @ 2024-08-05 976/week @ 2024-08-12 764/week @ 2024-08-19 977/week @ 2024-08-26 926/week @ 2024-09-02 937/week @ 2024-09-09

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