-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Tracking Issue for arithmetic that panics on overflow (strict_*
operations)
#118260
Comments
I have implemented something similar to this in the fixed crate, for example I used the prefix |
You mean |
I'm interested in contributing to fix issues with this or championing stabilization. (However, I haven't stabilized something before.)
What would a good next step be? |
Any redundant strict_ methods on unsigned types can help with programming generics and traits sometimes. Considering the utilization of such primitives, that "sometimes" may add up to a huge number of usecases. I'd love to see even better support for checked on language level like Zig does. For example, Rust could read |
Feature gate:
#![feature(strict_overflow_ops)]
This is a tracking issue for doing arithmetic that is guaranteed to panic on overflow, see the ACP for more details: rust-lang/libs-team#270.
Public API
For both signed and unsigned integers:
Additionally, signed integers have:
And unsigned integers have:
Steps / History
Unresolved Questions
strict_neg
on unsigned types? It's basically identical toassert_ne!(x, 0)
.strict_div
,strict_rem
,strict_div_euclid
andstrict_rem_euclid
on unsigned types? Those will never panic; they are identical to the non-strict versions.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: