Support types that can't be zero-initialized
This commit is contained in:
parent
44dfcd6bd0
commit
03463de743
1 changed files with 5 additions and 1 deletions
|
@ -304,7 +304,11 @@ fn AddCapture(comptime Root: type, comptime name: []const u8, comptime Val: type
|
|||
|
||||
fn addCapture(root: anytype, comptime name: []const u8, val: anytype) AddCapture(@TypeOf(root), name, @TypeOf(val)) {
|
||||
if (comptime std.mem.eql(u8, name, "_")) return root;
|
||||
var result = std.mem.zeroInit(AddCapture(@TypeOf(root), name, @TypeOf(val)), root);
|
||||
|
||||
var result: AddCapture(@TypeOf(root), name, @TypeOf(val)) = undefined;
|
||||
inline for (std.meta.fields(@TypeOf(root))) |f| {
|
||||
@field(result, f.name) = @field(root, f.name);
|
||||
}
|
||||
@field(result, name) = val;
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue