Skip to content

Handle should be an enum or packed struct #7

Description

@pfgithub

That way it will support ==. enum is preferred because then == .nil will work. packed struct is a one line and probably nonbreaking change.

eg:

-   return extern struct {
+   return enum (Id) {
...
-       id: Id = 0,
-       pub const nil = Self{ .id = 0 };
+       nil = 0,
+       _,
+       pub fn id(self: Self) Id {
+           return @intFromEnum(self);
+       }

And then you can do:

if (some_handle == .nil) ...
if (handle_a == handle_b) ...

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