From 671e2bd52fe822c66aa002f51d00c1919f20c61d Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 11 Jan 2025 02:44:11 -0800 Subject: [PATCH] isSlice: match pointer-to-array --- src/isSlice.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/isSlice.zig b/src/isSlice.zig index 9922a78bd80b474aa69899ab118bf32f47d2ccac..be8cb41f61e57ad4f26ae5e31d715864bed85951 100644 --- a/src/isSlice.zig +++ b/src/isSlice.zig @@ -4,7 +4,8 @@ const extras = @import("./lib.zig"); pub fn isSlice(comptime T: type) bool { if (comptime is(.Pointer)(T)) { - return @typeInfo(T).Pointer.size == .Slice; + if (@typeInfo(T).Pointer.size == .Slice) return true; + if (@typeInfo(T).Pointer.size == .One and is(.Array)(std.meta.Child(T))) return true; } return false; } @@ -25,3 +26,7 @@ test { try std.testing.expect(!isSlice(@TypeOf(array))); try std.testing.expect(!isSlice(@TypeOf(&array[0]))); } + +test { + try std.testing.expect(isSlice(@TypeOf(&[_]u32{ 66, 81, 99, 24, 36, 65, 24, 19, 25, 44 }))); +} -- 2.54.0