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 {
807807
808808pub const Case = enum { lower, upper };
809809
810fn formatSliceHexImpl(comptime case: Case) type {
810fn SliceHex(comptime case: Case) type {
811811 const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef";
812812
813813 return struct {
814 pub fn formatSliceHexImpl(
814 pub fn format(
815815 bytes: []const u8,
816816 comptime fmt: []const u8,
817817 options: std.fmt.FormatOptions,
......@@ -830,8 +830,8 @@ fn formatSliceHexImpl(comptime case: Case) type {
830830 };
831831}
832832
833const formatSliceHexLower = formatSliceHexImpl(.lower).formatSliceHexImpl;
834const formatSliceHexUpper = formatSliceHexImpl(.upper).formatSliceHexImpl;
833const formatSliceHexLower = SliceHex(.lower).format;
834const formatSliceHexUpper = SliceHex(.upper).format;
835835
836836/// Return a Formatter for a []const u8 where every byte is formatted as a pair
837837/// of lowercase hexadecimal digits.
......@@ -845,11 +845,11 @@ pub fn fmtSliceHexUpper(bytes: []const u8) std.fmt.Formatter(formatSliceHexUpper
845845 return .{ .data = bytes };
846846}
847847
848fn formatSliceEscapeImpl(comptime case: Case) type {
848fn SliceEscape(comptime case: Case) type {
849849 const charset = "0123456789" ++ if (case == .upper) "ABCDEF" else "abcdef";
850850
851851 return struct {
852 pub fn formatSliceEscapeImpl(
852 pub fn format(
853853 bytes: []const u8,
854854 comptime fmt: []const u8,
855855 options: std.fmt.FormatOptions,
......@@ -875,8 +875,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type {
875875 };
876876}
877877
878const formatSliceEscapeLower = formatSliceEscapeImpl(.lower).formatSliceEscapeImpl;
879const formatSliceEscapeUpper = formatSliceEscapeImpl(.upper).formatSliceEscapeImpl;
878const formatSliceEscapeLower = SliceEscape(.lower).format;
879const formatSliceEscapeUpper = SliceEscape(.upper).format;
880880
881881/// Return a Formatter for a []const u8 where every non-printable ASCII
882882/// 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
892892 return .{ .data = bytes };
893893}
894894
895fn formatSizeImpl(comptime base: comptime_int) type {
895fn Size(comptime base: comptime_int) type {
896896 return struct {
897 fn formatSizeImpl(
897 fn format(
898898 value: u64,
899899 comptime fmt: []const u8,
900900 options: FormatOptions,
......@@ -950,8 +950,8 @@ fn formatSizeImpl(comptime base: comptime_int) type {
950950 }
951951 };
952952}
953const formatSizeDec = formatSizeImpl(1000).formatSizeImpl;
954const formatSizeBin = formatSizeImpl(1024).formatSizeImpl;
953const formatSizeDec = Size(1000).format;
954const formatSizeBin = Size(1024).format;
955955
956956/// Return a Formatter for a u64 value representing a file size.
957957/// This formatter represents the number as multiple of 1000 and uses the SI
......@@ -1480,8 +1480,8 @@ pub const ParseIntError = error{
14801480/// writer: anytype,
14811481/// ) !void;
14821482///
1483pub fn Formatter(comptime format_fn: anytype) type {
1484 const Data = @typeInfo(@TypeOf(format_fn)).@"fn".params[0].type.?;
1483pub fn Formatter(comptime formatFn: anytype) type {
1484 const Data = @typeInfo(@TypeOf(formatFn)).@"fn".params[0].type.?;
14851485 return struct {
14861486 data: Data,
14871487 pub fn format(
......@@ -1490,7 +1490,7 @@ pub fn Formatter(comptime format_fn: anytype) type {
14901490 options: std.fmt.FormatOptions,
14911491 writer: anytype,
14921492 ) @TypeOf(writer).Error!void {
1493 try format_fn(self.data, fmt, options, writer);
1493 try formatFn(self.data, fmt, options, writer);
14941494 }
14951495 };
14961496}