diff options
| author | data-man <datamanrb@gmail.com> | 2020-05-25 01:50:22 +0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-24 20:44:17 -0400 |
| commit | b13dd3cf61fc01b189b5b585651f46de9319953e (patch) | |
| tree | b57a7af9eaaad4d471fd548897878df26d214895 /lib/std | |
| parent | dd05f2be80464deb8c98adb9b621364838c17f2b (diff) | |
| download | zig-b13dd3cf61fc01b189b5b585651f46de9319953e.tar.gz zig-b13dd3cf61fc01b189b5b585651f46de9319953e.zip | |
Treat vectors as indexable
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/meta/trait.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig index c99e1389f4..3be13057b5 100644 --- a/lib/std/meta/trait.zig +++ b/lib/std/meta/trait.zig @@ -273,17 +273,19 @@ pub fn isIndexable(comptime T: type) bool { } return true; } - return comptime is(.Array)(T); + return comptime is(.Array)(T) or is(.Vector)(T); } test "std.meta.trait.isIndexable" { const array = [_]u8{0} ** 10; const slice = @as([]const u8, &array); + const vector: meta.Vector(2, u32) = [_]u32{0} ** 2; testing.expect(isIndexable(@TypeOf(array))); testing.expect(isIndexable(@TypeOf(&array))); testing.expect(isIndexable(@TypeOf(slice))); testing.expect(!isIndexable(meta.Child(@TypeOf(slice)))); + testing.expect(isIndexable(@TypeOf(vector))); } pub fn isNumber(comptime T: type) bool { |
