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