Open dorianprill opened 2 years ago
Interesting! It may be possible to extend the way deku get's an id value if none is specified.
Relevant code section: https://github.com/sharksforarms/deku/blob/31ffd8db236e5153f57c66fac7db85acb277947a/deku-derive/src/macros/deku_read.rs#L182-L188
I suspect we'd need to actually look at the declaration and extract the discriminant value as oppose to generating runtime code since the only way of getting this value is by having a value construction of an enum (which we don't have when reading): https://doc.rust-lang.org/beta/unstable-book/language-features/arbitrary-enum-discriminant.html
I have an enum with 256 variants for which the discriminant is defined for all of them. Currently
deku
requires me to annotate every variant with#[deku(id = "N)]
although the discriminant is already defined in the code, which feels very redundant. Here is a minimal example, which does not work without the id annotation:If i omit
#[deku(id = "N)]
i get the following error:Would it be possible to check if the enum discriminants are exhaustively defined and remove the need for
#[deku(id = "N)]
in this case?