Oops, I misread your reply, I thought you wanted to not mix normal fields and bitfields. I’m only really against making “partial byte numbers” behave like real types, because they’re barely types in the Rust sense. I think some attribute-ad-hoc thing makes sense, like
#[repr(packed)]
struct K {
a: A,
#[bits(3)] b1: u8,
#[bits(1)] _: u8, // We'd allow _ as a field
// name only for this purpose, i.e.,
// equivalent of `uint8_t :1;`
#[bits(4)] b2: u8,
b: B,
}
Note that since the layout is implementation-defined in C, we might want to make the packed layout opt-in.