Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
amotzop opened this issue Apr 21, 2025 · 1 comment
Open
Labels
C-feature-request Category: a feature request, i.e. not implemented / a PR

Comments

@amotzop
Copy link

amotzop commented Apr 21, 2025

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))
@amotzop amotzop added the C-feature-request Category: a feature request, i.e. not implemented / a PR label Apr 21, 2025
@programmerjake
Copy link
Member

this RFC could probably help with converting vectors of pointers to a struct/enum to vectors of pointers to a member.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: a feature request, i.e. not implemented / a PR
Projects
None yet
Development

No branches or pull requests

2 participants