pub trait SignedAndUnsigned: Sized {
const MINIMUM: Self;
// Required methods
fn abs(&self) -> Option<Self>;
fn is_negative(&self) -> bool;
}
Expand description
Signed number operations implemented for both signed and unsigned numbers.
Required Associated Constants§
Required Methods§
Sourcefn abs(&self) -> Option<Self>
fn abs(&self) -> Option<Self>
The absolute value of a number. If the number is signed and equal to ::MIN, this operation would normally panic at overflow in debug or return ::MIN in release. This is undesired behavior, so we return None instead.
Sourcefn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Reports whether the number is negative.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.