mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
9 lines
298 B
Zig
9 lines
298 B
Zig
fn isFieldOptional(comptime T: type, field_index: usize) !bool {
|
|
const fields = @typeInfo(T).Struct.fields;
|
|
return switch (field_index) {
|
|
inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional,
|
|
else => return error.IndexOutOfBounds,
|
|
};
|
|
}
|
|
|
|
// syntax
|