| 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | const extras = @import("./lib.zig"); |
| 4 | |
| 5 | /// Asserts at comptime that L ⊆ R. |
| 6 | pub fn ensureFieldSubset(comptime L: type, comptime R: type) void { |
| 7 | for (std.meta.fields(L)) |item| { |
| 8 | if (!@hasField(R, item.name)) { |
| 9 | @compileError(std.fmt.comptimePrint("'{s}' field in {s} is not present in {s}", .{ item.name, @typeName(L), @typeName(R) })); |
| 10 | } |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | test { |
| 15 | comptime { |
| 16 | ensureFieldSubset(enum { |
| 17 | linux, |
| 18 | macos, |
| 19 | windows, |
| 20 | freebsd, |
| 21 | }, std.Target.Os.Tag); |
| 22 | } |
| 23 | } |