I need absolute value of i32
, there is stdlib function for that,
but it looks really strange:
pub const fn abs(self) -> i32
Because of it return i32
, it obviously can panic, as stated in its description.
The absolute value of i32::min_value() cannot be represented as an i32, and attempting to calculate it will cause an overflow. This means that code in debug mode will trigger a panic on this case
There are also checked_abs, overflow_abs, wrapping_abs,
but all of them return strange thing,
why there is no i32::abs
that just return u32
?