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

Add out-of-bounds assertions for setters #9

Closed Robbepop closed 5 years ago

Robbepop commented 5 years ago

Setting value through the generated set_* methods of #[bitfield] structs is currently unchecked. So for some bit specifiers users could potentially insert invalid values with the unwanted effect of them being cut-off.

We should make set_* method panic upon out-of-bounds inputs.

Robbepop commented 5 years ago

Implemented by https://github.com/Robbepop/modular-bitfield/commit/ea1dfc363f920cc2b4cd7c5b7f4418d0aa30de53.