mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
10 lines
298 B
Zig
10 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
|