bitmatch icon indicating copy to clipboard operation
bitmatch copied to clipboard

Possibility to handle case where bitpack discards bits?

Open ptomato opened this issue 2 years ago • 0 comments

Thanks for this wonderful crate, it makes very readable code!

As a feature request, it'd be convenient to be able to handle the case where set bits are getting discarded in bitpack!(). Sometimes the current behaviour of discarding bits is what I want, but sometimes it's not.

e.g. some API similar to bitpack!() that would get me a Result in the below case, which would be an error if the top 8 bits of a were not zero:

let a: u16 = 0x1234;
let b = bitpack!("0000_aaaa_0000_aaaa");

ptomato avatar May 15 '23 04:05 ptomato