format_unit(value: i64, type: utf8, unit: utf8) → utf8

Category: [strings](builtinsstrings)_

Render a base-unit value in a chosen literal unit, looking the factor up from a unit type by name — the inverse of literal-unit resolution, so it stays correct if the type's @unit factor changes.

ParameterTypeDescriptionRemarks
valuei64The stored value, in the type's base unit.
typeutf8The unit type's dotted name, e.g. "std.ByteSize".
unitutf8The unit to render in, e.g. "MiB".
returnsutf8The value divided by the unit's factor, suffixed with the unit (e.g. "5 MiB").
wcl
format_unit(5242880, "std.ByteSize", "MiB")   // render bytes as MiB → "5 MiB"