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

Page on "New Type Idiom" don't mention need of using repr(transparent) #1813

Open
Mart-Bogdan opened this issue Feb 4, 2024 · 0 comments
Open

Comments

@Mart-Bogdan
Copy link

Page that describes New Type Idiom https://doc.rust-lang.org/stable/rust-by-example/generics/new_types.html

Doesn't have any mention of #[repr(transparent)], and AFAIK it would be required for it to be zero cost abstraction and don't affect how it is passed in parameters (being passed in registers instead as a pointer to struct or whatever).

P.S. even documentation on repr transparent feature has newtype as example of intended usage

https://doc.rust-lang.org/1.26.2/unstable-book/language-features/repr-transparent.html

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

No branches or pull requests

1 participant