Warn users when calling textFormat with a non-tuple type
This commit is contained in:
parent
43d15b05c2
commit
c5ce02c084
3 changed files with 27 additions and 0 deletions
|
|
@ -1852,6 +1852,19 @@ pub fn loadCodepoints(text: [:0]const u8) RaylibError![]i32 {
|
|||
}
|
||||
|
||||
pub fn textFormat(text: [:0]const u8, args: anytype) [:0]const u8 {
|
||||
comptime {
|
||||
const info = @typeInfo(@TypeOf(args));
|
||||
switch (info) {
|
||||
.Struct => {
|
||||
if (!info.Struct.is_tuple)
|
||||
@compileError("Args should be in a tuple (call this function like textFormat(.{arg1, arg2, ...});)!");
|
||||
},
|
||||
else => {
|
||||
@compileError("Args should be in a tuple (call this function like textFormat(.{arg1, arg2, ...});)!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std.mem.span(@call(.auto, cdef.TextFormat, .{@as([*c]const u8, @ptrCast(text))} ++ args));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue