authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2024-09-03 22:16:11+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-08 11:30:20-07:00
log54b668f8a33e8466e4771e12f50069a068244640
tree5ce59791b29bccacc75e10e4d353450bf13bbad3
parentfb0028a0d7b43a2a5dd05f075ded22746f92faf6

std.fmt: Update casing of a few functions to match naming style guide


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

lib/std/fmt.zig+15-15
...@@ -807,11 +807,11 @@ test {...@@ -807,11 +807,11 @@ test {
807807
808pub const Case = enum { lower, upper };808pub const Case = enum { lower, upper };
809809
810fn formatSliceHexImpl(comptime case: Case) type {810fn 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";
812812
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}
832832
833const formatSliceHexLower = formatSliceHexImpl(.lower).formatSliceHexImpl;833const formatSliceHexLower = SliceHex(.lower).format;
834const formatSliceHexUpper = formatSliceHexImpl(.upper).formatSliceHexImpl;834const formatSliceHexUpper = SliceHex(.upper).format;
835835
836/// Return a Formatter for a []const u8 where every byte is formatted as a pair836/// 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}
847847
848fn formatSliceEscapeImpl(comptime case: Case) type {848fn 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";
850850
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}
877877
878const formatSliceEscapeLower = formatSliceEscapeImpl(.lower).formatSliceEscapeImpl;878const formatSliceEscapeLower = SliceEscape(.lower).format;
879const formatSliceEscapeUpper = formatSliceEscapeImpl(.upper).formatSliceEscapeImpl;879const formatSliceEscapeUpper = SliceEscape(.upper).format;
880880
881/// Return a Formatter for a []const u8 where every non-printable ASCII881/// Return a Formatter for a []const u8 where every non-printable ASCII
882/// character is escaped as \xNN, where NN is the character in lowercase882/// 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}
894894
895fn formatSizeImpl(comptime base: comptime_int) type {895fn 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}
953const formatSizeDec = formatSizeImpl(1000).formatSizeImpl;953const formatSizeDec = Size(1000).format;
954const formatSizeBin = formatSizeImpl(1024).formatSizeImpl;954const formatSizeBin = Size(1024).format;
955955
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 SI957/// 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///
1483pub fn Formatter(comptime format_fn: anytype) type {1483pub 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}