Skip to content

Improve guiIconText function using comptime so we don't have to cast enum to int - #161

Open
Selyatin wants to merge 2 commits into
raylib-zig:develfrom
Selyatin:devel
Open

Selyatin wants to merge 2 commits into
raylib-zig:develfrom
Selyatin:devel

Conversation

@Selyatin

Copy link
Copy Markdown

I simply used comptime to allow passing of either the GuiIconName enum directly, or an integer.

@Not-Nik

Not-Nik commented Jan 3, 2025

Copy link
Copy Markdown
Member

I reckon we don't need the integer thing at all right? Having the enum would be enough?

@ve-nt

ve-nt commented Jan 10, 2025

Copy link
Copy Markdown
Contributor

I know this isn't all that relevant but your icon code could be greatly simplified to this:

    const icon: c_int = switch (@TypeOf(iconId)) {
        GuiIconName => @intCast(@intFromEnum(iconId)),
        else => @intCast(iconId),
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants