Closed Robbepop closed 3 years ago
This would also be useful to skip compiler errors on unused fields.
Example:
#[bitfield]
pub struct MyBitfield {
pub foo: B2,
unused: B1,
pub bar: B5,
}
warning: associated function is never used: `unused`
|
338 | unused: B1,
| ^^^^^^
As a trick it should be noted that it will be possible to use __
(double wildcard) as identifier with #[skip]
:
#[bitfield]
pub struct Sparse {
a: bool,
#[skip] __: B10,
b: bool,
#[skip] __: B10,
}
Implemented in https://github.com/Robbepop/modular-bitfield/pull/49. Closed.
Using the proposed
#[skip]
attribute on bitfield fields it is possible to entirely skip code generation for the flagged field. Also this allows to have two optional parameters,getters
andsetters
that skips generation of the field's getters or setters respectively. By default#[skip]
skips both,#[skip(getters)]
only skips generation of getters,#[skip(setters)]
only skips generation ofsetters
and#[skip(getters, setters)]
is just equal to#[skip]
.