| ... | @@ -4,7 +4,8 @@ const extras = @import("./lib.zig"); | ... | @@ -4,7 +4,8 @@ const extras = @import("./lib.zig"); |
| 4 | | 4 | |
| 5 | pub fn isSlice(comptime T: type) bool { | 5 | pub fn isSlice(comptime T: type) bool { |
| 6 | if (comptime is(.Pointer)(T)) { | 6 | if (comptime is(.Pointer)(T)) { |
| 7 | return @typeInfo(T).Pointer.size == .Slice; | 7 | if (@typeInfo(T).Pointer.size == .Slice) return true; |
| | 8 | if (@typeInfo(T).Pointer.size == .One and is(.Array)(std.meta.Child(T))) return true; |
| 8 | } | 9 | } |
| 9 | return false; | 10 | return false; |
| 10 | } | 11 | } |
| ... | @@ -25,3 +26,7 @@ test { | ... | @@ -25,3 +26,7 @@ test { |
| 25 | try std.testing.expect(!isSlice(@TypeOf(array))); | 26 | try std.testing.expect(!isSlice(@TypeOf(array))); |
| 26 | try std.testing.expect(!isSlice(@TypeOf(&array[0]))); | 27 | try std.testing.expect(!isSlice(@TypeOf(&array[0]))); |
| 27 | } | 28 | } |
| | 29 | |
| | 30 | test { |
| | 31 | try std.testing.expect(isSlice(@TypeOf(&[_]u32{ 66, 81, 99, 24, 36, 65, 24, 19, 25, 44 }))); |
| | 32 | } |