What is the correct way to update bit fields in rust?
The update_sub1 function should update the sub1
bitfield with the u
value.
I read rust don't have C like bitfields in struct.
fn update_sub1 (v: u32, u: u8) -> u32 {
/* Need to update sub1 bits [26:23] alone with u value */
**.. code here to update the 26:23 bits with u value ..**
return v;
}
fn main()
{
/* x: [31- status, 26:23 - sub1, 7:0 - sub2 ] */
let x: u32 = 0x21;
let y = update_sub1(x, 12);
println!("{}", y);
}