-
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
Add saturating_abs and saturating_neg #59983
Comments
What do you expect them to return? Just |
The The
|
These seems reasonable. I'd suggest just making a PR with them unstable and seeing what libs says. By using |
Haven't done a PR for Rust yet so will take a look at the contribution guidelines and try to get along. |
Implement saturating_abs() and saturating_neg() functions for signed integer types Similar to wrapping_abs() / wrapping_neg() functions but saturating at the numeric bounds instead of wrapping around. Complements the existing set of functions with saturation mechanics. cc #59983
What's holding up stabilization on this? It seems relatively simple. |
In my opinion there is nothing specific holding this up from being stabilized. Initially I wanted to give it some time for others to comment, then forgot about. Added a PR for stabilization now. |
Stabilize saturating_abs and saturating_neg Stabilizes the following signed integer functions with saturation mechanics: * saturating_abs() * saturating_neg() Closes rust-lang#59983
It would be great to have
saturating_abs
andsaturating_neg
functions for signed integer types. The current work-around is using a pattern likechecked_$opr().unwrap_or($typ::max_value())
but having explicit functions would lift the corner-case knowledge "burden" from the user.The text was updated successfully, but these errors were encountered: