Robbepop / modular-bitfield

Macro to generate bitfields for structs that allow for modular use of enums.
Apache License 2.0
155 stars 40 forks source link

Implement `AsRef` and `AsMut` instances for `repr(uN)` bitfields #63

Open ollie-etl opened 3 years ago

ollie-etl commented 3 years ago

For repr(uN) bitfields, it'd be helpful to be able to view a reference to the bitfield as a reference to the representation type without copy.

The opposite is also true - there are occasions when I'd like to operate on a primitive type as though it were a bitfield.

ollie-etl commented 3 years ago

I'm happy to submit a RP if this is considered desirable ^

ollie-etl commented 3 years ago

I can't think of an implementation not requiring unsafe. Stdlib functions i.e. from_ne_byes copy.