Has there been any discussion into adding bitfields into Rust structs? C bitfields are tempting to use for packing/unpacking data, but they’re often dangerous to use because the ultimate layout of the struct is up to the compiler. So, for portability, C programmers are forced to use bitwise operations to pack and unpack data, which is unfortunate. It seems like if Rust gave a stronger guarantee of the layout of structs with bitfields, this could be an area where Rust is better than C for low-level programming.
Is there any reason we shouldn’t have bitfields with strong layout guarantees?