authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-08 14:49:38 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-08 14:49:38 -07:00
logdff9fd43ebf1046c70090bdccfeb2e4f1c0d584b
tree5b25281717c556d85b4d4ce7f07326ac5136fb6b
parentd7b9055564a14a5d0453ff050f73096e76a604ca
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add nprint methods for nio.fmt


1 files changed, 17 insertions(+), 2 deletions(-)

yaml.zig+17-2
...@@ -56,7 +56,11 @@ pub const Item = union(enum) {...@@ -56,7 +56,11 @@ pub const Item = union(enum) {
56 }56 }
57 }57 }
5858
59 pub fn format(self: Item, writer: *std.Io.Writer) !void {59 pub fn format(self: Value, writer: *std.Io.Writer) !void {
60 return nprint(self, writer);
61 }
62
63 pub fn nprint(self: Item, writer: anytype) !void {
60 try writer.writeAll("Item{");64 try writer.writeAll("Item{");
61 switch (self) {65 switch (self) {
62 .event => {66 .event => {
...@@ -119,6 +123,10 @@ pub const Value = union(enum) {...@@ -119,6 +123,10 @@ pub const Value = union(enum) {
119 }123 }
120124
121 pub fn format(self: Value, writer: *std.Io.Writer) !void {125 pub fn format(self: Value, writer: *std.Io.Writer) !void {
126 return nprint(self, writer);
127 }
128
129 pub fn nprint(self: Value, writer: anytype) !void {
122 try writer.writeAll("Value{");130 try writer.writeAll("Value{");
123 switch (self) {131 switch (self) {
124 .string => {132 .string => {
...@@ -134,6 +142,9 @@ pub const Value = union(enum) {...@@ -134,6 +142,9 @@ pub const Value = union(enum) {
134 }142 }
135 try writer.writeAll("]");143 try writer.writeAll("]");
136 },144 },
145 .anchor => {
146 //
147 },
137 }148 }
138 try writer.writeAll("}");149 try writer.writeAll("}");
139 }150 }
...@@ -189,7 +200,11 @@ pub const Mapping = struct {...@@ -189,7 +200,11 @@ pub const Mapping = struct {
189 return self.getT(k, .mapping);200 return self.getT(k, .mapping);
190 }201 }
191202
192 pub fn format(self: Mapping, writer: *std.Io.Writer) !void {203 pub fn format(self: Value, writer: *std.Io.Writer) !void {
204 return nprint(self, writer);
205 }
206
207 pub fn nprint(self: Mapping, writer: anytype) !void {
193 try writer.writeAll("{ ");208 try writer.writeAll("{ ");
194 for (self.items) |it| {209 for (self.items) |it| {
195 try writer.print("{s}: ", .{it.key});210 try writer.print("{s}: ", .{it.key});