authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-08-04 02:24:33 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-08-04 02:24:33 -07:00
log849860a0e6c3029353d476decb8d220bb7cc5389
tree47cddcec7043e561a35101bd2c3dd1936d4e1180
parente56b9fed6c0afd1c4d29bedc08c3899ffe1165e9

upstreaming local changes


1 files changed, 7 insertions(+), 4 deletions(-)

yaml.zig+7-4
......@@ -33,8 +33,7 @@ pub const Item = union(enum) {
3333 try writer.writeAll("Item{");
3434 switch (self) {
3535 .event => {
36 // try std.fmt.format(writer, "{s}", .{@tagName(self.event.type)});
37 try std.fmt.format(writer, "event {d}", .{self.event});
36 try std.fmt.format(writer, "event {}", .{self.event});
3837 },
3938 .kv, .document, .stream => {
4039 unreachable;
......@@ -114,8 +113,8 @@ pub const Mapping = struct {
114113 return null;
115114 }
116115
117 pub fn get_string(self: Mapping, k: string) string {
118 return if (self.get(k)) |v| v.string else "";
116 pub fn get_string(self: Mapping, k: string) ?string {
117 return self.getT(k, .string);
119118 }
120119
121120 pub fn get_string_array(self: Mapping, alloc: std.mem.Allocator, k: string) ![]string {
......@@ -134,6 +133,10 @@ pub const Mapping = struct {
134133 return list.toOwnedSlice();
135134 }
136135
136 pub fn getMap(self: Mapping, k: string) ?Mapping {
137 return self.getT(k, .mapping);
138 }
139
137140 pub fn format(self: Mapping, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void {
138141 _ = fmt;
139142 _ = options;