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

impl ZeroableInOption for all Zeroable? #246

Open
Rua opened this issue May 28, 2024 · 1 comment
Open

impl ZeroableInOption for all Zeroable? #246

Rua opened this issue May 28, 2024 · 1 comment

Comments

@Rua
Copy link

Rua commented May 28, 2024

Currently, Option<NonZeroI32> implements Zeroable, but Option<i32> does not. Would it be sound to implement ZeroableInOption for all Zeroable types? Since zero maps to None in a regular option, this would always produce a valid value wouldn't it?

@Lokathor
Copy link
Owner

The compiler doesn't guarantee that None has a tag value of 0 when it has a separately stored tag.

In practice, in current rust, i believe this is what would occur, but it would only be by coincidence, not a stability promise.

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

2 participants