Skip to content

Use opaque types instead of handle enumsΒ #115

@anyputer

Description

@anyputer

Instead of the following generated code:

pub const Instance = enum(usize) { null_handle = 0, _ };

we can make use of opaque types:

pub const Instance = opaque {}; // maybe *opaque {}?

This improves type safety with explicit nullability in generated code, and makes it easier to use with other C APIs that expect an opaque pointer. For example the instance argument in destroyInstance is not obviously nullable until you read the Vulkan spec, and null is obviously cleaner than .null_handle. This seems like a missed opportunity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions