Skip to content

Simplify use of enums #3

Open
Open

Description

@Traxar

It would be very nice for zig-sqlite to deal with converting enums to ints and back on its own. Having to write this at call site causes unnecessary boilerplate. As seen in this example:

try select.bind(.{
        .id = filter.id,
        .name = filter.name,
        .status = @enumToInt(filter.status),
    });

instead of just being able to:

try select.bind(filter);

Activity

  1. joeltg commented on Jan 29, 2024

    @joeltg
    Contributor

    I'm not opposed to adding this but I would want to avoid using @enumFromInt so that parsing an invalid value doesn't invoke undefined behavior.

    I'll keep this open as a note to myself for the next time I make some changes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions