Skip to content

Conversation

@omfj
Copy link
Collaborator

@omfj omfj commented Oct 27, 2025

No description provided.

@Reinsdyret Reinsdyret force-pushed the derive-enum branch 2 times, most recently from 658cc74 to 1f09d37 Compare November 11, 2025 12:10
@omfj omfj marked this pull request as ready for review November 11, 2025 12:13
   Implement struct-of-arrays transformation for enums with discriminant-based
   storage. Enums are decomposed into a separate discriminant array and union
   arrays for each field position.

   Features:
   - Generate discriminant-only enum with preserved explicit values
   - Create union types for each field position across variants
   - Support named and unnamed variant fields
   - Support unit variants and explicit discriminant expressions
   - Preserve enum visibility (pub, pub(crate), private)

   Safety:
   - Discriminant fields kept private in helper structs
   - Safe get_discriminant() accessor methods
   - Unsafe get_discriminant_mut() requires caller to maintain invariants
   - Prevents unsound discriminant/union field mismatches

   Tests added for discriminant access, named fields, and visibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants