Frago9876543210/endiannezz

Stable way to decl enums tag

Frago9876543210 opened this issue · 1 comments

stable rust:

#[derive(Io)]
#[endian(default_endian)] //only for Prim
#[repr(Prim)] //u32, i32, ...
enum Packet {
    #[tag(0xdeadbeef)]
    Foo(type: Io),
}

nightly rust: (WIP: enums branch)

#[derive(Io)]
#[endian(default_endian)] //only for Prim
#[repr(Prim)] //u32, i32, ...
enum Packet {
    Foo(type: Io, type1: Prim, ...) = 0xdeadbeef,
}

TODO:

  • Stable macro for struct-like & tuple enums
  • Custom repr types (#[wrapper(type)])
  • Zero cost write for unit enums? (enum as <repr_ty>)
  • More tests