The proposed filled: bool parameter for the #[bitfield] proc. macro allows to have bitfields with bit widths that are not divisible by 8 and therefore might contain invalid bit patterns that are inaccessible from the outside.
E.g. creating a #[bitfield(filled = false)] type with only 5 bits will leave 3 bits completely undefined.
For those #[bitfield] structs we no longer can define the byte conversion routines as infallible operations.
Instead they need to return Result and check whether the undefined bits are populated.
Not break the world
In this vein we will declare #[bitfield(specifier = true)] structs to be implicitly filled = false with the same effects.
Having #[bitfield(specifier = true, filled = true)] is only valid in case the bitfield struct has a bit width that is divisible by 8.
For a future release we might rethink this approach and instead no longer make #[bitfield(specifier = true)] implicitly be filled = false with all the implied consequences.
The proposed
filled: bool
parameter for the#[bitfield]
proc. macro allows to have bitfields with bit widths that are not divisible by 8 and therefore might contain invalid bit patterns that are inaccessible from the outside. E.g. creating a#[bitfield(filled = false)]
type with only 5 bits will leave 3 bits completely undefined.For those
#[bitfield]
structs we no longer can define the byte conversion routines as infallible operations. Instead they need to returnResult
and check whether the undefined bits are populated.Not break the world
In this vein we will declare
#[bitfield(specifier = true)]
structs to be implicitlyfilled = false
with the same effects. Having#[bitfield(specifier = true, filled = true)]
is only valid in case the bitfield struct has a bit width that is divisible by 8.For a future release we might rethink this approach and instead no longer make
#[bitfield(specifier = true)]
implicitly befilled = false
with all the implied consequences.