Skip to content
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

Use repr(transparent) for wrapper structs #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Use repr(transparent) for wrapper structs #32

wants to merge 1 commit into from

Conversation

LoganDark
Copy link

repr(transparent) provides stronger guarantees that the struct will have the exact same representation as its only field. And Context didn't even have an explicit representation, not even repr(C)!!

Because of all the transmutation that this library does between wrapper types and the types that they wrap, those guarantees are quite important, don't you think? :)

`repr(transparent)` provides stronger guarantees that the struct will have the exact same representation as its only field. And `Context` didn't even *have* an explicit representation, not even `repr(C)`!!

Because of all the transmutation that this library does between wrapper types and the types that they wrap, those guarantees are quite important, don't you think? :)
@LoganDark
Copy link
Author

Upon closer inspection it does look like Context does not need repr(transparent) since the library doesn't implement AsRef and such for it, but this is still a way to strengthen the safety of the wrapper types.

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.

None yet

1 participant