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

From<usize> missing for u64 #106050

Closed
MavenRain opened this issue Dec 22, 2022 · 4 comments
Closed

From<usize> missing for u64 #106050

MavenRain opened this issue Dec 22, 2022 · 4 comments

Comments

@MavenRain
Copy link

Why doesn't u64 implement From<usize>? The transformation is infallible.

@terrarier2111
Copy link
Contributor

It's probably because in the future platforms with usize > 64 bits might be added and this would lead to backwards compatability issues.

@MavenRain
Copy link
Author

Perhaps this should be a documentation issue, given that, since it isn't clear from what is present for the usize that the type is intended to be perpetually forward-looking: https://doc.rust-lang.org/std/primitive.usize.html

@KamilaBorowska
Copy link
Contributor

This was previously brought up in #30495. The issue is that in the future we may have 128-bit CPUs where usize would exceed u64, and From must not fail.

@MavenRain
Copy link
Author

Yeah, that definitely sounds right. Thank you guys for clarifying so quickly!

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

3 participants