-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tracking Issue i64 to u64 (as) #140870
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
Comments
The If you want to keep the same number value, and get an error if it is not representable, you could use let x: i64 = -10;
let y: Result<u64, _> = x.try_into(); // or u64::try_from(x)
println!("{:?}", y); // Err(TryFromIntError(()))
let x: i64 = 10;
let y: u64 = x.try_into().unwrap();
println!("{:?}", y); // 10 (Tracking issues are generally for tracking the implementation of things like new features, not for bug reports (which should use one of the other issue templates) or debugging questions (which should generally go on the user forum)) @rustbot label -C-tracking-issue -S-tracking-unimplemented +C-discussion |
Sorry for tags |
I would suggest asking rust questions on one of the community pages https://www.rust-lang.org/community or other sites like stackoverflow. |
https://www.collabora.com/news-and-blog/blog/2025/05/06/matt-godbolt-sold-me-on-rust-by-showing-me-c-plus-plus/ |
Clippy has lints that detect
You can enable them by promoting them to warnings/errors: |
Please help with error when do not worry transform i64 to u64
The text was updated successfully, but these errors were encountered: