feat(data_structures): add fieldless_enum! macro#19876
feat(data_structures): add fieldless_enum! macro#19876graphite-app[bot] merged 1 commit intomainfrom
fieldless_enum! macro#19876Conversation
Merging this PR will improve performance by 55.06%
Performance Changes
Comparing Footnotes
|
0442a25 to
b270112
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new optional fieldless_enum! macro to oxc_data_structures (behind a feature flag) to generate fieldless enums that expose a const VARIANTS array of all variants, enabling const-context iteration-like behavior.
Changes:
- Introduces
fieldless_enum!macro and unit tests under a newfieldless_enumfeature. - Exposes the new module behind
cfg(feature = "fieldless_enum")and wires the feature into the crate’sallfeature set. - Documents the capability in the crate README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_data_structures/src/lib.rs | Feature-gated export of the new fieldless_enum module. |
| crates/oxc_data_structures/src/fieldless_enum.rs | Implements and exports the fieldless_enum! macro + tests. |
| crates/oxc_data_structures/README.md | Adds the macro to the “Key Features” list. |
| crates/oxc_data_structures/Cargo.toml | Adds the fieldless_enum feature and includes it in all. |
b270112 to
9715ef3
Compare
9bd68f7 to
12b841e
Compare
9715ef3 to
904602d
Compare
Merge activity
|
Add a `fieldless_enum!` macro. This macro generates a `VARIANTS` constant on the type that lists all the enum's variants.
```rs
fieldless_enum! {
enum Foo {
A,
B,
C,
}
}
assert_eq!(Foo::VARIANTS, [Foo::A, Foo::B, Foo::C]);
```
This is useful for code which interacts with the enum, and needs to take some action on each variant.
904602d to
b3dceae
Compare

Add a
fieldless_enum!macro. This macro generates aVARIANTSconstant on the type that lists all the enum's variants.This is useful for code which interacts with the enum, and needs to take some action on each variant.