pub trait UnsignedAbs: Sized {
type Unsigned;
// Required method
fn unsigned_abs(self) -> Self::Unsigned;
}Expand description
Computes the absolute value as the unsigned counterpart type, which
cannot overflow (unlike abs, which overflows on MIN).
Required Associated Types§
Required Methods§
Sourcefn unsigned_abs(self) -> Self::Unsigned
fn unsigned_abs(self) -> Self::Unsigned
Computes the absolute value of self without any wrapping or
panicking.
use const_num_traits::UnsignedAbs;
assert_eq!(UnsignedAbs::unsigned_abs(-100i8), 100u8);
assert_eq!(UnsignedAbs::unsigned_abs(i8::MIN), 128u8);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".