-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally support specifying the bit-range of a field instead #28
Comments
To be clear, would this allow #[bitsize(4)]
#[derive(FromBits)]
struct Tiny {
#[at(2)]
field: u2
} what would you get for |
In my head it would basically expand to struct Tiny {
reserved_i: u2,
field: u2
} |
+1 to this idea. Additionally:
In general, I like the way it could potentially show and enforce the offsets that can easily be compared with a datasheet or other external specification showing the bit field we are modeling. Whereas if no offsets are set, then I have to do math to figure out if everything is correct, or go through the list and hope I figured out the size of each thing correctly, etc. It's all maybe a little nit-picky for most people, but seems like would be a nice touch. |
So that
is the same as
or
Here, we use a similar logic to enum discriminant counting:
The first field starts at 0, unless a range is given. The next field starts at the end of the previous field's range, unless a range is given.
This could be expanded, again similar to enums, to allow reordering.
The text was updated successfully, but these errors were encountered: