authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-15 16:05:49 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-15 16:05:49 -07:00
logcbb193154b831c2e56e0fce17f51c739c40278c1
treeb5a20135cf21a10bb19e295a021f9a23f0ef2b0e
parentb71f336f66b92556620cfcdff696e01c9bd4e205
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

support enums vs ints in ifequal and ifnotequal


1 files changed, 6 insertions(+), 0 deletions(-)

src/lib.zig+6
...@@ -236,6 +236,9 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val...@@ -236,6 +236,9 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
236 if (@typeInfo(@TypeOf(x)) == .@"enum" and comptime extras.isZigString(@TypeOf(y))) {236 if (@typeInfo(@TypeOf(x)) == .@"enum" and comptime extras.isZigString(@TypeOf(y))) {
237 return try doif(alloc, writer, body, bottom, data, ctx, opts, std.mem.eql(u8, @tagName(x), y));237 return try doif(alloc, writer, body, bottom, data, ctx, opts, std.mem.eql(u8, @tagName(x), y));
238 }238 }
239 if (TI == .@"enum" and @typeInfo(@TypeOf(y)) == .int) {
240 return doif(alloc, writer, body, bottom, data, ctx, opts, @intFromEnum(x) == y);
241 }
239 if (comptime extras.isSlice(@TypeOf(x, y))) {242 if (comptime extras.isSlice(@TypeOf(x, y))) {
240 return try doif(alloc, writer, body, bottom, data, ctx, opts, std.mem.eql(u8, x, y));243 return try doif(alloc, writer, body, bottom, data, ctx, opts, std.mem.eql(u8, x, y));
241 }244 }
...@@ -250,6 +253,9 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val...@@ -250,6 +253,9 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
250 if (@typeInfo(@TypeOf(x)) == .@"enum" and comptime extras.isZigString(@TypeOf(y))) {253 if (@typeInfo(@TypeOf(x)) == .@"enum" and comptime extras.isZigString(@TypeOf(y))) {
251 return try doif(alloc, writer, body, bottom, data, ctx, opts, !std.mem.eql(u8, @tagName(x), y));254 return try doif(alloc, writer, body, bottom, data, ctx, opts, !std.mem.eql(u8, @tagName(x), y));
252 }255 }
256 if (TI == .@"enum" and @typeInfo(@TypeOf(y)) == .int) {
257 return doif(alloc, writer, body, bottom, data, ctx, opts, @intFromEnum(x) != y);
258 }
253 if (comptime extras.isSlice(@TypeOf(x, y))) {259 if (comptime extras.isSlice(@TypeOf(x, y))) {
254 return try doif(alloc, writer, body, bottom, data, ctx, opts, !std.mem.eql(u8, x, y));260 return try doif(alloc, writer, body, bottom, data, ctx, opts, !std.mem.eql(u8, x, y));
255 }261 }