format_size
Formats a number of bytes with a binary unit and at most one decimal, such as "1.5 KiB".
Units are powers of 1024 (KiB, MiB, … EiB) and the value is rounded to the nearest
tenth, so 1023.96 KiB reads 1 MiB rather than 1024 KiB. A .0 is dropped. Only integer
arithmetic is used, so the result never depends on floating-point rounding.
parse_size reads it back.
Import
Section titled “Import”Cargo feature bytes (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
bytes | u64 | The size to format. |
Returns
Section titled “Returns”String — The formatted size.
