| ... | @@ -807,11 +807,11 @@ test { | ... | @@ -807,11 +807,11 @@ test { |
| 807 | | 807 | |
| 808 | pub const Case = enum { lower, upper }; | 808 | pub const Case = enum { lower, upper }; |
| 809 | | 809 | |
| 810 | fn formatSliceHexImpl(comptime case: Case) type { | 810 | fn SliceHex(comptime case: Case) type { |
| 811 | const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef"; | 811 | const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef"; |
| 812 | | 812 | |
| 813 | return struct { | 813 | return struct { |
| 814 | pub fn formatSliceHexImpl( | 814 | pub fn format( |
| 815 | bytes: []const u8, | 815 | bytes: []const u8, |
| 816 | comptime fmt: []const u8, | 816 | comptime fmt: []const u8, |
| 817 | options: std.fmt.FormatOptions, | 817 | options: std.fmt.FormatOptions, |
| ... | @@ -830,8 +830,8 @@ fn formatSliceHexImpl(comptime case: Case) type { | ... | @@ -830,8 +830,8 @@ fn formatSliceHexImpl(comptime case: Case) type { |
| 830 | }; | 830 | }; |
| 831 | } | 831 | } |
| 832 | | 832 | |
| 833 | const formatSliceHexLower = formatSliceHexImpl(.lower).formatSliceHexImpl; | 833 | const formatSliceHexLower = SliceHex(.lower).format; |
| 834 | const formatSliceHexUpper = formatSliceHexImpl(.upper).formatSliceHexImpl; | 834 | const formatSliceHexUpper = SliceHex(.upper).format; |
| 835 | | 835 | |
| 836 | /// Return a Formatter for a []const u8 where every byte is formatted as a pair | 836 | /// Return a Formatter for a []const u8 where every byte is formatted as a pair |
| 837 | /// of lowercase hexadecimal digits. | 837 | /// of lowercase hexadecimal digits. |
| ... | @@ -845,11 +845,11 @@ pub fn fmtSliceHexUpper(bytes: []const u8) std.fmt.Formatter(formatSliceHexUpper | ... | @@ -845,11 +845,11 @@ pub fn fmtSliceHexUpper(bytes: []const u8) std.fmt.Formatter(formatSliceHexUpper |
| 845 | return .{ .data = bytes }; | 845 | return .{ .data = bytes }; |
| 846 | } | 846 | } |
| 847 | | 847 | |
| 848 | fn formatSliceEscapeImpl(comptime case: Case) type { | 848 | fn SliceEscape(comptime case: Case) type { |
| 849 | const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef"; | 849 | const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef"; |
| 850 | | 850 | |
| 851 | return struct { | 851 | return struct { |
| 852 | pub fn formatSliceEscapeImpl( | 852 | pub fn format( |
| 853 | bytes: []const u8, | 853 | bytes: []const u8, |
| 854 | comptime fmt: []const u8, | 854 | comptime fmt: []const u8, |
| 855 | options: std.fmt.FormatOptions, | 855 | options: std.fmt.FormatOptions, |
| ... | @@ -875,8 +875,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type { | ... | @@ -875,8 +875,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type { |
| 875 | }; | 875 | }; |
| 876 | } | 876 | } |
| 877 | | 877 | |
| 878 | const formatSliceEscapeLower = formatSliceEscapeImpl(.lower).formatSliceEscapeImpl; | 878 | const formatSliceEscapeLower = SliceEscape(.lower).format; |
| 879 | const formatSliceEscapeUpper = formatSliceEscapeImpl(.upper).formatSliceEscapeImpl; | 879 | const formatSliceEscapeUpper = SliceEscape(.upper).format; |
| 880 | | 880 | |
| 881 | /// Return a Formatter for a []const u8 where every non-printable ASCII | 881 | /// Return a Formatter for a []const u8 where every non-printable ASCII |
| 882 | /// character is escaped as \xNN, where NN is the character in lowercase | 882 | /// character is escaped as \xNN, where NN is the character in lowercase |
| ... | @@ -892,9 +892,9 @@ pub fn fmtSliceEscapeUpper(bytes: []const u8) std.fmt.Formatter(formatSliceEscap | ... | @@ -892,9 +892,9 @@ pub fn fmtSliceEscapeUpper(bytes: []const u8) std.fmt.Formatter(formatSliceEscap |
| 892 | return .{ .data = bytes }; | 892 | return .{ .data = bytes }; |
| 893 | } | 893 | } |
| 894 | | 894 | |
| 895 | fn formatSizeImpl(comptime base: comptime_int) type { | 895 | fn Size(comptime base: comptime_int) type { |
| 896 | return struct { | 896 | return struct { |
| 897 | fn formatSizeImpl( | 897 | fn format( |
| 898 | value: u64, | 898 | value: u64, |
| 899 | comptime fmt: []const u8, | 899 | comptime fmt: []const u8, |
| 900 | options: FormatOptions, | 900 | options: FormatOptions, |
| ... | @@ -950,8 +950,8 @@ fn formatSizeImpl(comptime base: comptime_int) type { | ... | @@ -950,8 +950,8 @@ fn formatSizeImpl(comptime base: comptime_int) type { |
| 950 | } | 950 | } |
| 951 | }; | 951 | }; |
| 952 | } | 952 | } |
| 953 | const formatSizeDec = formatSizeImpl(1000).formatSizeImpl; | 953 | const formatSizeDec = Size(1000).format; |
| 954 | const formatSizeBin = formatSizeImpl(1024).formatSizeImpl; | 954 | const formatSizeBin = Size(1024).format; |
| 955 | | 955 | |
| 956 | /// Return a Formatter for a u64 value representing a file size. | 956 | /// Return a Formatter for a u64 value representing a file size. |
| 957 | /// This formatter represents the number as multiple of 1000 and uses the SI | 957 | /// This formatter represents the number as multiple of 1000 and uses the SI |
| ... | @@ -1480,8 +1480,8 @@ pub const ParseIntError = error{ | ... | @@ -1480,8 +1480,8 @@ pub const ParseIntError = error{ |
| 1480 | /// writer: anytype, | 1480 | /// writer: anytype, |
| 1481 | /// ) !void; | 1481 | /// ) !void; |
| 1482 | /// | 1482 | /// |
| 1483 | pub fn Formatter(comptime format_fn: anytype) type { | 1483 | pub fn Formatter(comptime formatFn: anytype) type { |
| 1484 | const Data = @typeInfo(@TypeOf(format_fn)).@"fn".params[0].type.?; | 1484 | const Data = @typeInfo(@TypeOf(formatFn)).@"fn".params[0].type.?; |
| 1485 | return struct { | 1485 | return struct { |
| 1486 | data: Data, | 1486 | data: Data, |
| 1487 | pub fn format( | 1487 | pub fn format( |
| ... | @@ -1490,7 +1490,7 @@ pub fn Formatter(comptime format_fn: anytype) type { | ... | @@ -1490,7 +1490,7 @@ pub fn Formatter(comptime format_fn: anytype) type { |
| 1490 | options: std.fmt.FormatOptions, | 1490 | options: std.fmt.FormatOptions, |
| 1491 | writer: anytype, | 1491 | writer: anytype, |
| 1492 | ) @TypeOf(writer).Error!void { | 1492 | ) @TypeOf(writer).Error!void { |
| 1493 | try format_fn(self.data, fmt, options, writer); | 1493 | try formatFn(self.data, fmt, options, writer); |
| 1494 | } | 1494 | } |
| 1495 | }; | 1495 | }; |
| 1496 | } | 1496 | } |