Skip to content

docs: add section explaining attributes and automatic Clone/Copy derives - #13

Merged
roeeshoshani merged 1 commit into
masterfrom
docs/attributes-and-derives
Jan 10, 2026
Merged

roeeshoshani merged 1 commit into
masterfrom
docs/attributes-and-derives

Conversation

@roeeshoshani

Copy link
Copy Markdown
Owner

Summary

This PR adds documentation to the README explaining how attributes are handled in the #[bitpiece] macro, following the changes made in commit 8e685a1.

Changes

New "Attributes and Derives" Section

Added a new section to the README that explains:

  1. Attribute propagation: User-provided attributes (like #[derive(...)]) are now applied to both the main generated type and the generated fields struct (when fields_struct is enabled).

  2. Automatic Clone and Copy: The Clone and Copy traits are automatically derived on all bitpiece types. Users do not need to (and should not) manually derive these traits.

  3. Deriving additional traits: Examples showing how to derive additional traits like Debug, PartialEq, Eq, Hash, and third-party traits like serde.

Updated Examples

All code examples throughout the README have been updated to remove Clone, Copy from the #[derive(...)] attributes, reflecting the new automatic derivation behavior.

Related

This documentation follows the changes made in PR #12 (commit 8e685a1) which changed how attributes are handled in the macros.

@roeeshoshani can click here to continue refining the PR

- Add new 'Attributes and Derives' section to README
- Explain that user attributes are applied to both main type and fields struct
- Document that Clone and Copy are automatically derived
- Update all examples to remove manual Clone, Copy derives
- Add examples showing how to derive additional traits like serde

Co-authored-by: openhands <openhands@all-hands.dev>
@roeeshoshani
roeeshoshani marked this pull request as ready for review January 10, 2026 23:51
@roeeshoshani
roeeshoshani merged commit 136be04 into master Jan 10, 2026
1 check passed
@roeeshoshani
roeeshoshani deleted the docs/attributes-and-derives branch January 10, 2026 23:51
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.

2 participants