Skip to content

Add bitfield attribute "derive(...)".#135

Open
flaviojs wants to merge 2 commits into
danlehmann:mainfrom
flaviojs:add-derive-from
Open

Add bitfield attribute "derive(...)".#135
flaviojs wants to merge 2 commits into
danlehmann:mainfrom
flaviojs:add-derive-from

Conversation

@flaviojs

@flaviojs flaviojs commented Jun 16, 2026

Copy link
Copy Markdown

Can derive From to convert between the type and the base type, allowing generics that use the base type.
Example usage in bitbybit/tests/derive.rs.
Fixes #107
Fixes #132

Can derive Debug, equivalent to bitfield attribute "debug".
Optional, it makes more sense to me.

Can derive Default, equivalent to bitfield attribute "default = 0".
Optional, does not override the value provided by "default = X".

The no_compile test outputs were updated to match the current stable version "rustc 1.96.0 (ac68faa20 2026-05-25)".

@flaviojs

Copy link
Copy Markdown
Author

Note that I did not apply "cargo fmt" because the original code is not formatted with it.

Can derive From to convert between the type and the base type,
allowing generics that use the base type.
Example usage in bitbybit/tests/derive.rs.

Can derive Debug, equivalent to bitfield attribute "debug".
Optional, it makes more sense to me.

Can derive Default, equivalent to bitfield attribute "default = 0".
Optional, does not override the value provided by "default = X".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add endian conversion functions for bitfields backed by standard types Suggestion: Traits for converting from/to raw types

1 participant