Trait SignedAndUnsigned

Source
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§

Source

const MINIMUM: Self

Minimum value for the type.

Required Methods§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl SignedAndUnsigned for i8

Source§

const MINIMUM: Self = -128i8

Source§

fn abs(&self) -> Option<i8>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for i16

Source§

const MINIMUM: Self = -32_768i16

Source§

fn abs(&self) -> Option<i16>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for i32

Source§

const MINIMUM: Self = -2_147_483_648i32

Source§

fn abs(&self) -> Option<i32>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for i64

Source§

const MINIMUM: Self = -9_223_372_036_854_775_808i64

Source§

fn abs(&self) -> Option<i64>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for isize

Source§

const MINIMUM: Self = -9_223_372_036_854_775_808isize

Source§

fn abs(&self) -> Option<isize>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for u8

Source§

const MINIMUM: Self = 0u8

Source§

fn abs(&self) -> Option<u8>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for u16

Source§

const MINIMUM: Self = 0u16

Source§

fn abs(&self) -> Option<u16>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for u32

Source§

const MINIMUM: Self = 0u32

Source§

fn abs(&self) -> Option<u32>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for u64

Source§

const MINIMUM: Self = 0u64

Source§

fn abs(&self) -> Option<u64>

Source§

fn is_negative(&self) -> bool

Source§

impl SignedAndUnsigned for usize

Source§

const MINIMUM: Self = 0usize

Source§

fn abs(&self) -> Option<usize>

Source§

fn is_negative(&self) -> bool

Implementors§