From 168f3420e9b12e7b48af9e859f6c7c2df23eb81d Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 28 Jun 2023 23:14:45 -0700 Subject: [PATCH] support comparing slices in ifequal and ifnotequal --- src/lib.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.zig b/src/lib.zig index a95a219eddd488b8576dd453efc0f98602018322..835e1c64f882286c92b1a02b9edb6f1a9dfb4ec1 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -170,6 +170,9 @@ inline fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.V if (@typeInfo(@TypeOf(x)) == .Enum and comptime std.meta.trait.isZigString(@TypeOf(y))) { return try doif(alloc, writer, body, bottom, data, ctx, opts, std.mem.eql(u8, @tagName(x), y)); } + if (comptime std.meta.trait.isSlice(@TypeOf(x, y))) { + return try doif(alloc, writer, body, bottom, data, ctx, opts, std.mem.eql(u8, x, y)); + } try doif(alloc, writer, body, bottom, data, ctx, opts, x == y); }, .ifnotequal => { @@ -178,6 +181,9 @@ inline fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.V if (@typeInfo(@TypeOf(x)) == .Enum and comptime std.meta.trait.isZigString(@TypeOf(y))) { return try doif(alloc, writer, body, bottom, data, ctx, opts, !std.mem.eql(u8, @tagName(x), y)); } + if (comptime std.meta.trait.isSlice(@TypeOf(x, y))) { + return try doif(alloc, writer, body, bottom, data, ctx, opts, !std.mem.eql(u8, x, y)); + } try doif(alloc, writer, body, bottom, data, ctx, opts, x != y); }, } -- 2.54.0