Skip to content

Support missing enum variants on remote derives - #553

Merged
djkoloski merged 3 commits into
rkyv:mainfrom
MaxOhn:remote-non-exhaustive
Sep 16, 2024
Merged

djkoloski merged 3 commits into
rkyv:mainfrom
MaxOhn:remote-non-exhaustive

Conversation

@MaxOhn

@MaxOhn MaxOhn commented Sep 15, 2024

Copy link
Copy Markdown
Contributor

When deriving Serialize, omitting variants from remote enums is currently not supported, neither are remote enums that are #[non_exhaustive].

This PR solves these two by adding the #[rkyv(other)] attribute on enum variants. The attribute may be specified only once, namely on the very last variant which must be of unit type.

The attribute essentially adds a _ => { ... } match branch for serialization which needs to be at the bottom. The code can likely be refactored to lift that restriction but I figured it's fine to require users to put their catch-all variant at the bottom.

@djkoloski
djkoloski merged commit 04aa8ce into rkyv:main Sep 16, 2024
@MaxOhn
MaxOhn deleted the remote-non-exhaustive branch September 16, 2024 08:32
s3bk pushed a commit to s3bk/rkyv that referenced this pull request Aug 24, 2026
* Support missing variants for remote impls

* Fix formatting

* Extend remote example
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