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 {...@@ -426,10 +426,8 @@ pub const Document = struct {
426 doc = null;426 doc = null;
427 }427 }
428428
429 pub fn format(this: *const Document, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {429 pub fn nprint(this: *const Document, writer: anytype) !void {
430 _ = fmt;430 return nio.fmt.format(writer, "{}", .{this.root});
431 _ = options;
432 return std.fmt.format(writer, "{}", .{this.root});
433 }431 }
434432
435 pub fn stringify(this: *const Document, writer: anytype, space: Space, indent: u8) Instance(@TypeOf(writer)).WriteError!void {433 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) {...@@ -449,10 +447,8 @@ pub const ValueIndex = enum(u32) {
449 empty_object = 14,447 empty_object = 14,
450 _,448 _,
451449
452 pub fn format(this: ValueIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {450 pub fn nprint(this: ValueIndex, writer: anytype) !void {
453 _ = fmt;451 return nio.fmt.format(writer, "{}", .{this.v()});
454 _ = options;
455 return std.fmt.format(writer, "{}", .{this.v()});
456 }452 }
457453
458 fn stringify(this: ValueIndex, writer: anytype, space: Space, indent: u8) !void {454 fn stringify(this: ValueIndex, writer: anytype, space: Space, indent: u8) !void {
...@@ -508,15 +504,13 @@ pub const Value = union(enum(u8)) {...@@ -508,15 +504,13 @@ pub const Value = union(enum(u8)) {
508504
509 const Tag = std.meta.Tag(@This());505 const Tag = std.meta.Tag(@This());
510506
511 pub fn format(this: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {507 pub fn nprint(this: Value, writer: anytype) !void {
512 _ = options;
513 _ = fmt;
514 return switch (this) {508 return switch (this) {
515 .zero => unreachable,509 .zero => unreachable,
516 .null => std.fmt.format(writer, "null", .{}),510 .null => nio.fmt.format(writer, "null", .{}),
517 .true => std.fmt.format(writer, "true", .{}),511 .true => nio.fmt.format(writer, "true", .{}),
518 .false => std.fmt.format(writer, "false", .{}),512 .false => nio.fmt.format(writer, "false", .{}),
519 inline .object, .array, .string, .number => |t| std.fmt.format(writer, "{}", .{t}),513 inline .object, .array, .string, .number => |t| nio.fmt.format(writer, "{}", .{t}),
520 };514 };
521 }515 }
522516
...@@ -537,9 +531,7 @@ pub const Array = []align(1) const ValueIndex;...@@ -537,9 +531,7 @@ pub const Array = []align(1) const ValueIndex;
537pub const StringIndex = enum(u32) {531pub const StringIndex = enum(u32) {
538 _,532 _,
539533
540 pub fn format(this: StringIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {534 pub fn nprint(this: StringIndex, writer: anytype) !void {
541 _ = options;
542 _ = fmt;
543 try writer.writeAll("\"");535 try writer.writeAll("\"");
544 try writer.writeAll(this.to());536 try writer.writeAll(this.to());
545 try writer.writeAll("\"");537 try writer.writeAll("\"");
...@@ -562,10 +554,7 @@ pub const StringIndex = enum(u32) {...@@ -562,10 +554,7 @@ pub const StringIndex = enum(u32) {
562pub const ArrayIndex = enum(u32) {554pub const ArrayIndex = enum(u32) {
563 _,555 _,
564556
565 pub fn format(this: ArrayIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {557 pub fn nprint(this: ArrayIndex, writer: anytype) !void {
566 _ = options;
567 _ = fmt;
568
569 const items = this.to();558 const items = this.to();
570 try writer.writeAll("[");559 try writer.writeAll("[");
571 for (items, 0..) |item, i| {560 for (items, 0..) |item, i| {
...@@ -602,9 +591,7 @@ pub const ArrayIndex = enum(u32) {...@@ -602,9 +591,7 @@ pub const ArrayIndex = enum(u32) {
602pub const ObjectIndex = enum(u32) {591pub const ObjectIndex = enum(u32) {
603 _,592 _,
604593
605 pub fn format(this: ObjectIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {594 pub fn nprint(this: ObjectIndex, writer: anytype) !void {
606 _ = options;
607 _ = fmt;
608 const keys, const values = this.to();595 const keys, const values = this.to();
609 try writer.writeAll("{");596 try writer.writeAll("{");
610 for (keys, values, 0..) |k, v, i| {597 for (keys, values, 0..) |k, v, i| {
...@@ -696,9 +683,7 @@ pub const ObjectIndex = enum(u32) {...@@ -696,9 +683,7 @@ pub const ObjectIndex = enum(u32) {
696pub const NumberIndex = enum(u32) {683pub const NumberIndex = enum(u32) {
697 _,684 _,
698685
699 pub fn format(this: NumberIndex, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {686 pub fn nprint(this: NumberIndex, writer: anytype) !void {
700 _ = options;
701 _ = fmt;
702 try writer.writeAll(this.to());687 try writer.writeAll(this.to());
703 }688 }
704689