| ... | @@ -273,17 +273,19 @@ pub fn isIndexable(comptime T: type) bool { | ... | @@ -273,17 +273,19 @@ pub fn isIndexable(comptime T: type) bool { |
| 273 | } | 273 | } |
| 274 | return true; | 274 | return true; |
| 275 | } | 275 | } |
| 276 | return comptime is(.Array)(T); | 276 | return comptime is(.Array)(T) or is(.Vector)(T); |
| 277 | } | 277 | } |
| 278 | | 278 | |
| 279 | test "std.meta.trait.isIndexable" { | 279 | test "std.meta.trait.isIndexable" { |
| 280 | const array = [_]u8{0} ** 10; | 280 | const array = [_]u8{0} ** 10; |
| 281 | const slice = @as([]const u8, &array); | 281 | const slice = @as([]const u8, &array); |
| | 282 | const vector: meta.Vector(2, u32) = [_]u32{0} ** 2; |
| 282 | | 283 | |
| 283 | testing.expect(isIndexable(@TypeOf(array))); | 284 | testing.expect(isIndexable(@TypeOf(array))); |
| 284 | testing.expect(isIndexable(@TypeOf(&array))); | 285 | testing.expect(isIndexable(@TypeOf(&array))); |
| 285 | testing.expect(isIndexable(@TypeOf(slice))); | 286 | testing.expect(isIndexable(@TypeOf(slice))); |
| 286 | testing.expect(!isIndexable(meta.Child(@TypeOf(slice)))); | 287 | testing.expect(!isIndexable(meta.Child(@TypeOf(slice)))); |
| | 288 | testing.expect(isIndexable(@TypeOf(vector))); |
| 287 | } | 289 | } |
| 288 | | 290 | |
| 289 | pub fn isNumber(comptime T: type) bool { | 291 | pub fn isNumber(comptime T: type) bool { |