sharksforarms / deku

Declarative binary reading and writing: bit-level, symmetric, serialization/deserialization
Apache License 2.0
1.05k stars 54 forks source link

Support unit structure `struct S;` in derive-macro `DekuWrite` #449

Closed yuan-y-chang closed 2 weeks ago

yuan-y-chang commented 2 weeks ago

We should support unit structure struct S; since struct S {} and struct S(); are allowed to derive DekuWrite.

#[derive(DekuWrite)] // error: expected tuple struct or tuple variant, found unit struct `Zero`
#[deku(magic = b"\x00")]
struct Zero;

And DekuRead is no error here.

wcampbell0x2a commented 2 weeks ago

https://github.com/sharksforarms/deku/pull/450 should fix this.