#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

#1191 in Text processing

Download history 786/week @ 2024-01-11 788/week @ 2024-01-18 628/week @ 2024-01-25 901/week @ 2024-02-01 791/week @ 2024-02-08 802/week @ 2024-02-15 853/week @ 2024-02-22 857/week @ 2024-02-29 969/week @ 2024-03-07 746/week @ 2024-03-14 806/week @ 2024-03-21 839/week @ 2024-03-28 702/week @ 2024-04-04 737/week @ 2024-04-11 648/week @ 2024-04-18 769/week @ 2024-04-25

2,966 downloads per month
Used in 12 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");

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