std.fmt: more descriptive names for impl functions

This is a workaround for a limitation of the C backend.
This commit is contained in:
Jacob Young 2022-11-27 16:26:41 -05:00 committed by Andrew Kelley
parent 9cb06f3b8b
commit 906120bc2c

View File

@ -827,7 +827,7 @@ fn formatSliceHexImpl(comptime case: Case) type {
const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef"; const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef";
return struct { return struct {
pub fn f( pub fn formatSliceHexImpl(
bytes: []const u8, bytes: []const u8,
comptime fmt: []const u8, comptime fmt: []const u8,
options: std.fmt.FormatOptions, options: std.fmt.FormatOptions,
@ -846,8 +846,8 @@ fn formatSliceHexImpl(comptime case: Case) type {
}; };
} }
const formatSliceHexLower = formatSliceHexImpl(.lower).f; const formatSliceHexLower = formatSliceHexImpl(.lower).formatSliceHexImpl;
const formatSliceHexUpper = formatSliceHexImpl(.upper).f; const formatSliceHexUpper = formatSliceHexImpl(.upper).formatSliceHexImpl;
/// Return a Formatter for a []const u8 where every byte is formatted as a pair /// Return a Formatter for a []const u8 where every byte is formatted as a pair
/// of lowercase hexadecimal digits. /// of lowercase hexadecimal digits.
@ -865,7 +865,7 @@ fn formatSliceEscapeImpl(comptime case: Case) type {
const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef"; const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef";
return struct { return struct {
pub fn f( pub fn formatSliceEscapeImpl(
bytes: []const u8, bytes: []const u8,
comptime fmt: []const u8, comptime fmt: []const u8,
options: std.fmt.FormatOptions, options: std.fmt.FormatOptions,
@ -891,8 +891,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type {
}; };
} }
const formatSliceEscapeLower = formatSliceEscapeImpl(.lower).f; const formatSliceEscapeLower = formatSliceEscapeImpl(.lower).formatSliceEscapeImpl;
const formatSliceEscapeUpper = formatSliceEscapeImpl(.upper).f; const formatSliceEscapeUpper = formatSliceEscapeImpl(.upper).formatSliceEscapeImpl;
/// Return a Formatter for a []const u8 where every non-printable ASCII /// Return a Formatter for a []const u8 where every non-printable ASCII
/// character is escaped as \xNN, where NN is the character in lowercase /// character is escaped as \xNN, where NN is the character in lowercase
@ -910,7 +910,7 @@ pub fn fmtSliceEscapeUpper(bytes: []const u8) std.fmt.Formatter(formatSliceEscap
fn formatSizeImpl(comptime radix: comptime_int) type { fn formatSizeImpl(comptime radix: comptime_int) type {
return struct { return struct {
fn f( fn formatSizeImpl(
value: u64, value: u64,
comptime fmt: []const u8, comptime fmt: []const u8,
options: FormatOptions, options: FormatOptions,
@ -958,8 +958,8 @@ fn formatSizeImpl(comptime radix: comptime_int) type {
}; };
} }
const formatSizeDec = formatSizeImpl(1000).f; const formatSizeDec = formatSizeImpl(1000).formatSizeImpl;
const formatSizeBin = formatSizeImpl(1024).f; const formatSizeBin = formatSizeImpl(1024).formatSizeImpl;
/// Return a Formatter for a u64 value representing a file size. /// Return a Formatter for a u64 value representing a file size.
/// This formatter represents the number as multiple of 1000 and uses the SI /// This formatter represents the number as multiple of 1000 and uses the SI