aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/inline_prong_range.zig
blob: 3d68324c5684acc04787c7ef2185b1bfa37f7132 (plain)
1
2
3
4
5
6
7
8
9
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