std: fmt.format to io.Writer.print
allows reverting format -> deprecatedFormat, plus I think this is a nicer place for the function.
This commit is contained in:
@@ -501,7 +501,7 @@ pub fn Serializer(Writer: type) type {
|
||||
try self.int(val);
|
||||
},
|
||||
.float, .comptime_float => try self.float(val),
|
||||
.bool, .null => try std.fmt.deprecatedFormat(self.writer, "{}", .{val}),
|
||||
.bool, .null => try std.fmt.format(self.writer, "{}", .{val}),
|
||||
.enum_literal => try self.ident(@tagName(val)),
|
||||
.@"enum" => try self.ident(@tagName(val)),
|
||||
.pointer => |pointer| {
|
||||
@@ -616,7 +616,7 @@ pub fn Serializer(Writer: type) type {
|
||||
/// Serialize an integer.
|
||||
pub fn int(self: *Self, val: anytype) Writer.Error!void {
|
||||
//try self.writer.printInt(val, 10, .lower, .{});
|
||||
try std.fmt.deprecatedFormat(self.writer, "{d}", .{val});
|
||||
try std.fmt.format(self.writer, "{d}", .{val});
|
||||
}
|
||||
|
||||
/// Serialize a float.
|
||||
@@ -631,12 +631,12 @@ pub fn Serializer(Writer: type) type {
|
||||
} else if (std.math.isNegativeZero(val)) {
|
||||
return self.writer.writeAll("-0.0");
|
||||
} else {
|
||||
try std.fmt.deprecatedFormat(self.writer, "{d}", .{val});
|
||||
try std.fmt.format(self.writer, "{d}", .{val});
|
||||
},
|
||||
.comptime_float => if (val == 0) {
|
||||
return self.writer.writeAll("0");
|
||||
} else {
|
||||
try std.fmt.deprecatedFormat(self.writer, "{d}", .{val});
|
||||
try std.fmt.format(self.writer, "{d}", .{val});
|
||||
},
|
||||
else => comptime unreachable,
|
||||
}
|
||||
@@ -659,7 +659,7 @@ pub fn Serializer(Writer: type) type {
|
||||
var buf: [8]u8 = undefined;
|
||||
const len = std.unicode.utf8Encode(val, &buf) catch return error.InvalidCodepoint;
|
||||
const str = buf[0..len];
|
||||
try std.fmt.deprecatedFormat(self.writer, "'{f}'", .{std.zig.fmtChar(str)});
|
||||
try std.fmt.format(self.writer, "'{f}'", .{std.zig.fmtChar(str)});
|
||||
}
|
||||
|
||||
/// Like `value`, but always serializes `val` as a tuple.
|
||||
@@ -717,7 +717,7 @@ pub fn Serializer(Writer: type) type {
|
||||
|
||||
/// Like `value`, but always serializes `val` as a string.
|
||||
pub fn string(self: *Self, val: []const u8) Writer.Error!void {
|
||||
try std.fmt.deprecatedFormat(self.writer, "\"{f}\"", .{std.zig.fmtString(val)});
|
||||
try std.fmt.format(self.writer, "\"{f}\"", .{std.zig.fmtString(val)});
|
||||
}
|
||||
|
||||
/// Options for formatting multiline strings.
|
||||
|
||||
Reference in New Issue
Block a user