authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 20:47:20 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 20:47:20 -07:00
log5fa3919fa85a9e72e35eb14c62f390f99d00dad4
tree5b9f42e31b4a6b201f6cb67427c08b64ce24dcbc
parentfb918b08846233573467f5df41fcc3b733155663
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

migrate the format methods to nprint


1 files changed, 13 insertions(+), 28 deletions(-)

json.zig+13-28
......@@ -426,10 +426,8 @@ pub const Document = struct {
426426 doc = null;
427427 }
428428
429 pub fn format(this: *const Document, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
430 _ = fmt;
431 _ = options;
432 return std.fmt.format(writer, "{}", .{this.root});
429 pub fn nprint(this: *const Document, writer: anytype) !void {
430 return nio.fmt.format(writer, "{}", .{this.root});
433431 }
434432
435433 pub fn stringify(this: *const Document, writer: anytype, space: Space, indent: u8) Instance(@TypeOf(writer)).WriteError!void {
......@@ -449,10 +447,8 @@ pub const ValueIndex = enum(u32) {
449447 empty_object = 14,
450448 _,
451449
452 pub fn format(this: ValueIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
453 _ = fmt;
454 _ = options;
455 return std.fmt.format(writer, "{}", .{this.v()});
450 pub fn nprint(this: ValueIndex, writer: anytype) !void {
451 return nio.fmt.format(writer, "{}", .{this.v()});
456452 }
457453
458454 fn stringify(this: ValueIndex, writer: anytype, space: Space, indent: u8) !void {
......@@ -508,15 +504,13 @@ pub const Value = union(enum(u8)) {
508504
509505 const Tag = std.meta.Tag(@This());
510506
511 pub fn format(this: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
512 _ = options;
513 _ = fmt;
507 pub fn nprint(this: Value, writer: anytype) !void {
514508 return switch (this) {
515509 .zero => unreachable,
516 .null => std.fmt.format(writer, "null", .{}),
517 .true => std.fmt.format(writer, "true", .{}),
518 .false => std.fmt.format(writer, "false", .{}),
519 inline .object, .array, .string, .number => |t| std.fmt.format(writer, "{}", .{t}),
510 .null => nio.fmt.format(writer, "null", .{}),
511 .true => nio.fmt.format(writer, "true", .{}),
512 .false => nio.fmt.format(writer, "false", .{}),
513 inline .object, .array, .string, .number => |t| nio.fmt.format(writer, "{}", .{t}),
520514 };
521515 }
522516
......@@ -537,9 +531,7 @@ pub const Array = []align(1) const ValueIndex;
537531pub const StringIndex = enum(u32) {
538532 _,
539533
540 pub fn format(this: StringIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
541 _ = options;
542 _ = fmt;
534 pub fn nprint(this: StringIndex, writer: anytype) !void {
543535 try writer.writeAll("\"");
544536 try writer.writeAll(this.to());
545537 try writer.writeAll("\"");
......@@ -562,10 +554,7 @@ pub const StringIndex = enum(u32) {
562554pub const ArrayIndex = enum(u32) {
563555 _,
564556
565 pub fn format(this: ArrayIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
566 _ = options;
567 _ = fmt;
568
557 pub fn nprint(this: ArrayIndex, writer: anytype) !void {
569558 const items = this.to();
570559 try writer.writeAll("[");
571560 for (items, 0..) |item, i| {
......@@ -602,9 +591,7 @@ pub const ArrayIndex = enum(u32) {
602591pub const ObjectIndex = enum(u32) {
603592 _,
604593
605 pub fn format(this: ObjectIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
606 _ = options;
607 _ = fmt;
594 pub fn nprint(this: ObjectIndex, writer: anytype) !void {
608595 const keys, const values = this.to();
609596 try writer.writeAll("{");
610597 for (keys, values, 0..) |k, v, i| {
......@@ -696,9 +683,7 @@ pub const ObjectIndex = enum(u32) {
696683pub const NumberIndex = enum(u32) {
697684 _,
698685
699 pub fn format(this: NumberIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
700 _ = options;
701 _ = fmt;
686 pub fn nprint(this: NumberIndex, writer: anytype) !void {
702687 try writer.writeAll(this.to());
703688 }
704689