sharksforarms / deku

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

Add bound attribute to restrict derived impls #341

Open MegaBluejay opened 1 year ago

MegaBluejay commented 1 year ago

Analogous to serde's

This allows using generics without restricting them in the struct definition

The use-case for me is parsing into a raw form, then post-processing some fields, while retaining most of the structure. With this both can use the same generic type, and only the raw form needs to implement DekuRead/DekuWrite.

Inferring the bounds automatically would be better, but I'm not up to writing that right now.