mod: bump zig version to 0.16.0

This commit is contained in:
2026-05-19 23:08:32 +02:00
parent bdf58f5102
commit 24a08e0e62
25 changed files with 721 additions and 701 deletions
+28 -22
View File
@@ -56,21 +56,29 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
const b_fields = @typeInfo(B).@"union".fields;
const b_fields_tag = @typeInfo(B).@"union".tag_type.?;
const b_enum_fields = @typeInfo(b_fields_tag).@"enum".fields;
var fields: [a_fields.len + b_fields.len]std.builtin.Type.UnionField = undefined;
var enum_fields: [a_fields.len + b_fields.len]std.builtin.Type.EnumField = undefined;
var field_names: [a_fields.len + b_fields.len][:0]const u8 = undefined;
var field_types: [a_fields.len + b_fields.len]type = undefined;
var enum_names: [a_fields.len + b_fields.len][:0]const u8 = undefined;
// FIX can I not use `comptime_int`? `u4` would be actually incorrect!
// can I get the correct size through the length of the fields?
var enum_values: [a_fields.len + b_fields.len]u4 = undefined;
var i: usize = 0;
for (a_fields, a_enum_fields) |field, enum_field| {
fields[i] = field;
field_names[i] = field.name;
field_types[i] = field.type;
var enum_f = enum_field;
enum_f.value = i;
enum_fields[i] = enum_f;
enum_names[i] = enum_f.name;
enum_values[i] = i;
i += 1;
}
for (b_fields, b_enum_fields) |field, enum_field| {
fields[i] = field;
field_names[i] = field.name;
field_types[i] = field.type;
var enum_f = enum_field;
enum_f.value = i;
enum_fields[i] = enum_f;
enum_names[i] = enum_f.name;
enum_values[i] = i;
i += 1;
}
@@ -92,24 +100,22 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
j += 1;
}
const EventType = @Type(.{ .int = .{
.signedness = .unsigned,
.bits = @bitSizeOf(@TypeOf(i)) - @clz(i),
} });
const EventType = @Int(.unsigned, @bitSizeOf(@TypeOf(i)) - @clz(i));
const Event = @Type(.{ .@"enum" = .{
.tag_type = EventType,
.fields = enum_fields[0..],
.decls = &.{},
.is_exhaustive = true,
} });
const Event = @Enum(
EventType,
.exhaustive,
&enum_names,
&enum_values,
);
return @Type(.{ .@"union" = .{
.layout = .auto,
.tag_type = Event,
.fields = fields[0..],
.decls = &.{},
} });
return @Union(
.auto,
Event,
&field_names,
&field_types,
&@splat(.{}),
);
}
/// Determine whether the provided type `T` is a tagged union: `union(enum)`.