From e9934ab8814348845bddbfb6ea3a271c49397e20 Mon Sep 17 00:00:00 2001 From: Arran Ireland Date: Sat, 28 Dec 2024 01:28:34 +0000 Subject: [PATCH 1/2] build: Fix examples for zig 0.13.0 --- examples/build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/build.zig b/examples/build.zig index 2b03ba0c..c583e4dd 100644 --- a/examples/build.zig +++ b/examples/build.zig @@ -22,7 +22,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = exe_name, - .root_source_file = .{ .path = example_path }, + .root_source_file = b.path(example_path), .target = target, .optimize = optimize, }); From 426e87c3084f141ba4bca4eac21e8d8cd4ed615a Mon Sep 17 00:00:00 2001 From: Arran Ireland Date: Sat, 28 Dec 2024 01:29:19 +0000 Subject: [PATCH 2/2] examples: Fix examples for zig 0.13.0 --- examples/bool-deserializer/main.zig | 8 +++++--- examples/seq-deserializer/main.zig | 8 ++++---- examples/seq-serializer/main.zig | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/bool-deserializer/main.zig b/examples/bool-deserializer/main.zig index 60a7abd8..3a013cee 100644 --- a/examples/bool-deserializer/main.zig +++ b/examples/bool-deserializer/main.zig @@ -35,7 +35,7 @@ fn Deserializer(comptime Reader: type) type { self.tokens.deinit(); } - fn deserializeBool(self: *Self, ally: ?std.mem.Allocator, v: anytype) Error!@TypeOf(v).Value { + fn deserializeBool(self: *Self, ally: std.mem.Allocator, v: anytype) Error!@TypeOf(v).Value { const token = try self.tokens.next(); if (token == .true or token == .false) { return try v.visitBool(ally, De, token == .true); @@ -47,13 +47,15 @@ fn Deserializer(comptime Reader: type) type { } pub fn main() anyerror!void { + const page_ally = std.heap.page_allocator; + var fbs = std.io.fixedBufferStream("true"); const reader = fbs.reader(); - var d = Deserializer(@TypeOf(reader)).init(std.heap.page_allocator, reader); + var d = Deserializer(@TypeOf(reader)).init(page_ally, reader); defer d.deinit(); - const v = try getty.deserialize(null, bool, d.deserializer()); + const v = try getty.deserialize(page_ally, bool, d.deserializer()); std.debug.print("{}, {}\n", .{ v, @TypeOf(v) }); } diff --git a/examples/seq-deserializer/main.zig b/examples/seq-deserializer/main.zig index b957b612..7042c9dd 100644 --- a/examples/seq-deserializer/main.zig +++ b/examples/seq-deserializer/main.zig @@ -36,7 +36,7 @@ fn Deserializer(comptime Reader: type) type { self.tokens.deinit(); } - fn deserializeBool(self: *Self, ally: ?std.mem.Allocator, v: anytype) Error!@TypeOf(v).Value { + fn deserializeBool(self: *Self, ally: std.mem.Allocator, v: anytype) Error!@TypeOf(v).Value { const token = try self.tokens.next(); if (token == .true or token == .false) { return try v.visitBool(ally, De, token == .true); @@ -45,7 +45,7 @@ fn Deserializer(comptime Reader: type) type { return error.InvalidType; } - fn deserializeSeq(self: *Self, ally: ?std.mem.Allocator, v: anytype) Error!@TypeOf(v).Value { + fn deserializeSeq(self: *Self, ally: std.mem.Allocator, v: anytype) Error!@TypeOf(v).Value { const token = try self.tokens.next(); if (token == .array_begin) { var sa = SeqAccess{ .de = self }; @@ -66,7 +66,7 @@ fn Deserializer(comptime Reader: type) type { }, ); - fn nextElementSeed(self: *@This(), ally: ?std.mem.Allocator, seed: anytype) Error!?@TypeOf(seed).Value { + fn nextElementSeed(self: *@This(), ally: std.mem.Allocator, seed: anytype) Error!?@TypeOf(seed).Value { // If ']' is encountered, return null if (try self.de.tokens.peekNextTokenType() == .array_end) { return null; @@ -92,5 +92,5 @@ pub fn main() anyerror!void { const v = try getty.deserialize(page_ally, std.ArrayList(bool), d.deserializer()); defer v.deinit(); - std.debug.print("{any}, {}\n", .{ v.items, @TypeOf(v) }); + std.debug.print("{any}, {}\n", .{ v.value, @TypeOf(v) }); } diff --git a/examples/seq-serializer/main.zig b/examples/seq-serializer/main.zig index b19daccc..5dde6e9b 100644 --- a/examples/seq-serializer/main.zig +++ b/examples/seq-serializer/main.zig @@ -75,6 +75,6 @@ pub fn main() anyerror!void { try getty.serialize(null, list, s); // std.BoundedArray - var arr = try std.BoundedArray(bool, 2).fromSlice(&.{ true, false }); + const arr = try std.BoundedArray(bool, 2).fromSlice(&.{ true, false }); try getty.serialize(null, arr, s); }