Closed
Description
Feature gate: #![feature(int_abs_diff)]
This is a tracking issue for a method to compute the absolute difference between two integers.
Public API
This adds the method T::abs_diff(other: T) -> U
to all built-in Rust integer types, both signed and unsigned, where U
is the unsigned equivalent of T
(or just T
itself it it already was unsigned). This method always computes the mathematical absolute difference between the two numbers correctly, without any risk of overflow. Because the output is an unsigned type the result is always representable.
Steps / History
- Issue: Add a method for computing the absolute difference between unsigned integers #62111
Note: scope has been expanded to implementabs_diff
for all integers, not just unsigned integers. - Implementation: Added abs_diff for integer types. #88780
- Final comment period (FCP)
- Stabilization PR: Stabilize int_abs_diff in 1.60.0. #93735
Unresolved Questions
- None yet.