Open Apanatshka opened 7 months ago
I wasn't able to generate const fn
getters because the getter call a method from the (internal) BitRange
trait which is not const
. I tried to make it const
but it seems to not be possible to make a method from a trait const
(see rustc --explain E0379
).
If you find a satisfying workaround that doesn't imply getting rid of the trait, I would be happy to implement it.
I read up on that explanation and the linked RFC. Looks like const traits aren't a thing (yet?). All I can think of to do is to generate your current BitRange
implementations as loose pub const fn
s, generate the BitRange
implementations to use those, and have the exposed macro's of bitfield use the const
version so they can be const
themselves. Then the users of the crate can choose between the const
functions and the more convenient trait
abstraction.
I'm using
bitfield
combined withvarlen
, which allowsconst
expressions over fields to be used to compute lengths of arrays. Would it be possible to generateconst fn
getters for bit fields so I can use those in my computation?