Skip to content

Better ergonomics for working with vector of pointers to structs/enums #459

Open
@amotzop

Description

@amotzop

I think there should be some support for working with vectors of pointers to structs. Specifically I think the following features would be helpful:

  • Having a way to pass from pointers to a struct/enum to pointers to a member. Today this can be done by casting to const* u8, adding the offset_of! and casting back, but I think a dedicated macro for this would be cleaner. Also the enum part needs a nightly feature to work (offset_of_enum)
  • Having a way to "match" a vector of enums, i.e., given a variant getting a mask encoding which lanes point to instances of this variant. Today there is no general way of doing it (you can try doing the same trick to get the discriminant, but there's no way to know what is the relevant discriminant value for each variant, and it becomes even trickier if the discriminant is optimized in some way (e.g. the niche optimization))

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: a feature request, i.e. not implemented / a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions