| ... | @@ -502,3 +502,15 @@ pub fn parse_json(alloc: std.mem.Allocator, input: string) !std.json.ValueTree { | ... | @@ -502,3 +502,15 @@ pub fn parse_json(alloc: std.mem.Allocator, input: string) !std.json.ValueTree { |
| 502 | var p = std.json.Parser.init(alloc, .alloc_always); | 502 | var p = std.json.Parser.init(alloc, .alloc_always); |
| 503 | return try p.parse(input); | 503 | return try p.parse(input); |
| 504 | } | 504 | } |
| | 505 | |
| | 506 | pub fn isArrayOf(comptime T: type) std.meta.trait.TraitFn { |
| | 507 | const Closure = struct { |
| | 508 | pub fn trait(comptime C: type) bool { |
| | 509 | return switch (@typeInfo(C)) { |
| | 510 | .Array => |ti| ti.child == T, |
| | 511 | else => false, |
| | 512 | }; |
| | 513 | } |
| | 514 | }; |
| | 515 | return Closure.trait; |
| | 516 | } |