Skip to content

feat: make enums ABI-compatible - #30

Merged
mkroening merged 1 commit into
mainfrom
try-from-primitive
Sep 7, 2026
Merged

feat: make enums ABI-compatible#30
mkroening merged 1 commit into
mainfrom
try-from-primitive

Conversation

@mkroening

Copy link
Copy Markdown
Member

I believe implementing TryFromPrimitive, which also returns the original number in the error case, is more useful than having Unknown catch-all variants for all enums.

This also makes the types ABI-compatible, which is still to be used with care when using foreign data, but that is how all Rust enums work until we have unnamed enum variants.

@mkroening
mkroening requested a review from phip1611 August 21, 2026 06:56
@mkroening mkroening self-assigned this Aug 21, 2026

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but please check CI again

@mkroening

Copy link
Copy Markdown
Member Author

Oh, right. I should have tested this. This does not work for types where we provide spec-guided typed accessors, so mmio and pci. I have undone those changes and left in the ones where we don't do volatile accesses but merely represent data.

@mkroening
mkroening added this pull request to the merge queue Sep 7, 2026
Merged via the queue into main with commit edadf1c Sep 7, 2026
12 of 14 checks passed
@mkroening
mkroening deleted the try-from-primitive branch September 7, 2026 10:01
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.

2 participants