authorgravatar for 96026401+fdfdjfk3@users.noreply.github.comfdfdjfk3 <96026401+fdfdjfk3@users.noreply.github.com> 2024-09-02 04:21:59-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-09-02 14:21:59+03:00
loga670f5519568b893f17e1ea06a0646e4726e21ca
tree2d7fd48fd2af0437089a93f157f56f9474aff8b8
parent13da34955cf9c8f91e0a144ebd46de5e75cacae6
signaturebadge-check Signed by PGP key B5690EEEBB952194

std.fmt.fmtIntSize*: document when precision is ignored


1 files changed, 2 insertions(+), 1 deletions(-)

lib/std/fmt.zig+2-1
......@@ -950,13 +950,13 @@ fn formatSizeImpl(comptime base: comptime_int) type {
950950 }
951951 };
952952}
953
954953const formatSizeDec = formatSizeImpl(1000).formatSizeImpl;
955954const formatSizeBin = formatSizeImpl(1024).formatSizeImpl;
956955
957956/// Return a Formatter for a u64 value representing a file size.
958957/// This formatter represents the number as multiple of 1000 and uses the SI
959958/// measurement units (kB, MB, GB, ...).
959/// Format option `precision` is ignored when `value` is less than 1kB
960960pub fn fmtIntSizeDec(value: u64) std.fmt.Formatter(formatSizeDec) {
961961 return .{ .data = value };
962962}
......@@ -964,6 +964,7 @@ pub fn fmtIntSizeDec(value: u64) std.fmt.Formatter(formatSizeDec) {
964964/// Return a Formatter for a u64 value representing a file size.
965965/// This formatter represents the number as multiple of 1024 and uses the IEC
966966/// measurement units (KiB, MiB, GiB, ...).
967/// Format option `precision` is ignored when `value` is less than 1KiB
967968pub fn fmtIntSizeBin(value: u64) std.fmt.Formatter(formatSizeBin) {
968969 return .{ .data = value };
969970}