From bd079b42d9ea7350abc43a0b7f6f39de96a57aa6 Mon Sep 17 00:00:00 2001 From: torque Date: Thu, 23 Nov 2023 18:37:10 -0800 Subject: [PATCH] compile with zig master I was actually anticipating a bit more stdlib breakage than this, so I ended up just shimming it. Well, it works and also still works with 0.11.0, which is cool. --- build.zig.zon | 7 +++++++ src/parser/value.zig | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 8fe8886..878c10c 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,4 +2,11 @@ .name = "nice-data", .version = "0.1.0-pre", .dependencies = .{}, + .paths = .{ + "src", + "build.zig", + "build.zig.zon", + "license", + "readme.md", + }, } diff --git a/src/parser/value.zig b/src/parser/value.zig index c65b1b1..0811889 100644 --- a/src/parser/value.zig +++ b/src/parser/value.zig @@ -9,6 +9,11 @@ // CONDITIONS OF ANY KIND, either express or implied. const std = @import("std"); +const hasFn = if (@hasDecl(std.meta, "trait")) struct { + fn hasFn(comptime T: type, comptime name: []const u8) bool { + return std.meta.trait.hasFn(name)(T); + } +}.hasFn else std.meta.hasFn; const Options = @import("../parser.zig").Options; @@ -183,7 +188,7 @@ pub const Value = union(enum) { } }, .Struct => |stt| { - if (comptime std.meta.trait.hasFn("deserializeNice")(T)) + if (comptime hasFn(T, "deserializeNice")) return T.deserializeNice(self, allocator, options); if (stt.is_tuple) { @@ -244,7 +249,7 @@ pub const Value = union(enum) { } }, .Enum => { - if (comptime std.meta.trait.hasFn("deserializeNice")(T)) + if (comptime hasFn(T, "deserializeNice")) return T.deserializeNice(self, allocator, options); switch (self) { @@ -269,7 +274,7 @@ pub const Value = union(enum) { } }, .Union => |unn| { - if (comptime std.meta.trait.hasFn("deserializeNice")(T)) + if (comptime hasFn(T, "deserializeNice")) return T.deserializeNice(self, allocator, options); if (unn.tag_type == null) @compileError("Cannot deserialize into untagged union " ++ @typeName(T));