Skip to content

Support tuple structs in wrap_impl!#867

Open
HarrisonMc555 wants to merge 2 commits intogyscos:mainfrom
HarrisonMc555:wrap-impl-tuple-struct
Open

Support tuple structs in wrap_impl!#867
HarrisonMc555 wants to merge 2 commits intogyscos:mainfrom
HarrisonMc555:wrap-impl-tuple-struct

Conversation

@HarrisonMc555
Copy link
Copy Markdown

Change the fragment specifier used in wrap_impl! from ident to tt. Using ident was sufficient for "standard" structs with named fields. However, tuple structs are accessed via index numbers, which are not matched by ident. Although using literal for tuple indices seems like it should work, it does not.

Sidestep this issue by matching an tt, i.e. any valid token tree.

Fixes #866

Change the fragment specifier used in `wrap_impl!` from `ident` to
`tt`. Using `ident` was sufficient for "standard" structs with named
fields. However, tuple structs are accessed via index numbers, which
are not matched by `ident`. Although using `literal` for tuple indices
seems like it should work, it does not.

Sidestep this issue by matching an `tt`, i.e. any valid token
tree.
@gyscos
Copy link
Copy Markdown
Owner

gyscos commented Apr 12, 2026

Thanks for the PR!

Would you mind adding a unit test that makes sure this macro works with both a named struct and a tuple struct?

@HarrisonMc555
Copy link
Copy Markdown
Author

Sure thing! There was already a doc test, but I added a unit test. Right now it's mostly just exercising that you can invoke the macro without causing compiler errors. Let me know if there's anything else you'd like to see tested.

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.

Wrapping views in tuple structs

2 participants