fn CheckAllAllocationFailuresExtraArgs(comptime TestFn: type) type 1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214fn CheckAllAllocationFailuresExtraArgs(comptime TestFn: type) type {
switch (@typeInfo(@typeInfo(TestFn).@"fn".return_type.?)) {
.error_union => |info| {
if (info.payload != void) {
@compileError("Return type must be !void");
}
},
else => @compileError("Return type must be !void"),
}
const ArgsTuple = std.meta.ArgsTuple(TestFn);
const field_types = @typeInfo(ArgsTuple).@"struct".field_types;
if (field_types.len == 0 or field_types[0] != std.mem.Allocator) {
@compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");
}
var extra_args: [field_types.len - 1]type = undefined;
for (&extra_args, field_types[1..]) |*arg, field_type| {
arg.* = field_type;
}
return @Tuple(&extra_args);
}