DVUI

findMatchingStructOption

Returns the option from the passed in options tuple for type T.

Parameters

#
T:type
type
field_name:[]const u8
[]const u8
struct_options:anytype
anytype

Source

Implementation

#
pub fn findMatchingStructOption(T: type, field_name: []const u8, struct_options: anytype) ?StructOptions(T) {
    inline for (struct_options) |struct_option| {
        if (@TypeOf(struct_option).StructT == T) {
            // Check if these options are for a specific field.
            if (struct_option.for_field_name) |for_name| {
                if (std.mem.eql(u8, field_name, for_name)) {
                    return struct_option;
                }
            } else {
                return struct_option;
            }
        }
    }
    return null;
}