Skip to content
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

Supporting Option for enums #17

Open
mkeeter opened this issue May 31, 2022 · 0 comments
Open

Supporting Option for enums #17

mkeeter opened this issue May 31, 2022 · 0 comments

Comments

@mkeeter
Copy link
Contributor

mkeeter commented May 31, 2022

It would be nice to support Option<T> where T is a simple enum type.

This isn't supported by either ssmarshal or zerocopy. I think we'd want to implement a special zerocopy case like we're doing for bool already. It turns out that the compiler is smart enough to pack None into an unused enum slot, which you can find using

    let a: Option<TofinoSeqError> = None;
    let a: u8 = unsafe { std::mem::transmute(a) };

so we could use this value for the None case.

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

No branches or pull requests

1 participant