To skip code generation for a field f we already planned to implement the #[skip] attribute.
However, users still have to be creative to come up with some proper name for that field.
What would be better, was if fields named _ (wildcard) would simply be treated as skipped fields.
Example
use modular_bitfield::prelude::*;
#[bitfield]
pub struct Sparse {
a: bool,
_: B10, // We skip the next 10 bits.
b: bool,
_: B10, // We skip the next 10 bits again.
}
Problem
The problem with this proposed solution is that in Rust _ is not parsed as identifier but as a keyword and therefore causes problems beyond what is easily (without hacks) achievable in a proc. macro today.
This is no longer really needed since with the most recent update it is now possible to have double wildcard + #[skip] have a similar effect as proposed here. Closed.
To skip code generation for a field
f
we already planned to implement the#[skip]
attribute. However, users still have to be creative to come up with some proper name for that field. What would be better, was if fields named_
(wildcard) would simply be treated as skipped fields.Example
Problem
The problem with this proposed solution is that in Rust
_
is not parsed as identifier but as a keyword and therefore causes problems beyond what is easily (without hacks) achievable in a proc. macro today.