Skip to content

Supporting Option for enums #17

@mkeeter

Description

@mkeeter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions