Title: Add proc-macros for DeepClone and ByteRepr · Issue #216 · Cpp2Rust/cpp2rust · GitHub
Open Graph Title: Add proc-macros for DeepClone and ByteRepr · Issue #216 · Cpp2Rust/cpp2rust
X Title: Add proc-macros for DeepClone and ByteRepr · Issue #216 · Cpp2Rust/cpp2rust
Description: Currently we generate: #[derive(Default)] pub struct woff2_Point { pub x: Value
Open Graph Description: Currently we generate: #[derive(Default)] pub struct woff2_Point { pub x: Value
X Description: Currently we generate: #[derive(Default)] pub struct woff2_Point { pub x: Value<i32>, pub y: Value<i32>, pub on_curve: Value<bool>, } impl Clone for woff2_Point { fn clone(&se...
Opengraph URL: https://github.com/Cpp2Rust/cpp2rust/issues/216
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add proc-macros for DeepClone and ByteRepr","articleBody":"Currently we generate:\n\n```rs\n#[derive(Default)]\npub struct woff2_Point {\n pub x: Value\u003ci32\u003e,\n pub y: Value\u003ci32\u003e,\n pub on_curve: Value\u003cbool\u003e,\n}\nimpl Clone for woff2_Point {\n fn clone(\u0026self) -\u003e Self {\n let mut this = Self {\n x: Rc::new(RefCell::new((*self.x.borrow()))),\n y: Rc::new(RefCell::new((*self.y.borrow()))),\n on_curve: Rc::new(RefCell::new((*self.on_curve.borrow()))),\n };\n this\n }\n}\nimpl ByteRepr for woff2_Point {\n fn to_bytes(\u0026self, buf: \u0026mut [u8]) {\n (*self.x.borrow()).to_bytes(\u0026mut buf[0..4]);\n (*self.y.borrow()).to_bytes(\u0026mut buf[4..8]);\n (*self.on_curve.borrow()).to_bytes(\u0026mut buf[8..9]);\n }\n fn from_bytes(buf: \u0026[u8]) -\u003e Self {\n Self {\n x: Rc::new(RefCell::new(\u003ci32\u003e::from_bytes(\u0026buf[0..4]))),\n y: Rc::new(RefCell::new(\u003ci32\u003e::from_bytes(\u0026buf[4..8]))),\n on_curve: Rc::new(RefCell::new(\u003cbool\u003e::from_bytes(\u0026buf[8..9]))),\n }\n }\n}\n```\n\nThat's a lot of code. We can write 2 proc-macros: `DeepClone` and `ByteRepr` and generate the following code instead:\n\n```rs\n#[derive(Default, DeepClone, ByteRepr)]\npub struct woff2_Point {\n pub x: Value\u003ci32\u003e,\n pub y: Value\u003ci32\u003e,\n pub on_curve: Value\u003cbool\u003e,\n}\n```","author":{"url":"https://github.com/lucic71","@type":"Person","name":"lucic71"},"datePublished":"2026-07-01T09:26:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/216/cpp2rust/issues/216"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a45b07f8-1007-a2c5-b75b-ff0fe81cb46e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C93E:390CE:3DCB1:531F5:6A4D90F8 |
| html-safe-nonce | 821380cc78b6b4826958f2ad9c21b1734ccd64232a875ace8f616a2d3c801e0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTNFOjM5MENFOjNEQ0IxOjUzMUY1OjZBNEQ5MEY4IiwidmlzaXRvcl9pZCI6IjMyNzI3MjE3ODM3NzAxNTczMDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b3bd6e747895ce5599819c050c5aead95d01df842c7faccb9808220796b4e0ef |
| hovercard-subject-tag | issue:4784233453 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Cpp2Rust/cpp2rust/216/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2b4dfa333253dabbd49e7d299cd5e09db6d3f3a43794ee00d526c447b3ae41de/Cpp2Rust/cpp2rust/issues/216 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2b4dfa333253dabbd49e7d299cd5e09db6d3f3a43794ee00d526c447b3ae41de/Cpp2Rust/cpp2rust/issues/216 |
| og:image:alt | Currently we generate: #[derive(Default)] pub struct woff2_Point { pub x: Value |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lucic71 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/Cpp2Rust/cpp2rust git https://github.com/Cpp2Rust/cpp2rust.git |
| octolytics-dimension-user_id | 197474191 |
| octolytics-dimension-user_login | Cpp2Rust |
| octolytics-dimension-repository_id | 1183095779 |
| octolytics-dimension-repository_nwo | Cpp2Rust/cpp2rust |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1183095779 |
| octolytics-dimension-repository_network_root_nwo | Cpp2Rust/cpp2rust |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 74e2a9c78f1e38588de4f25885878349d721eedf |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width