Integer

Trait Integer 

Source
pub trait Integer
where Self: Copy + Shl<usize, Output = Self> + Shr<usize, Output = Self> + BitAnd<Output = Self> + BitOr<Output = Self> + BitAndAssign + BitOrAssign + Not<Output = Self> + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign + Ord + Sum + Display + Debug + Default + Binary,
{ const ZERO: Self; const ONE: Self; const TWO: Self; const MIN: Self; const MAX: Self; const MAX_U64: u64; const N_BITS: usize; const N_BITS_U64: u64; const SIGNED: bool; // Provided methods fn is_neg(&self) -> bool { ... } fn abs(&self) -> Self { ... } fn negate(&self) -> Self { ... } }

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Source

const MIN: Self

Source

const MAX: Self

Source

const MAX_U64: u64

Source

const N_BITS: usize

Source

const N_BITS_U64: u64

Source

const SIGNED: bool

Provided Methods§

Source

fn is_neg(&self) -> bool

Checks, if the integer is negative.

Source

fn abs(&self) -> Self

Returns the absolute value of the integer.

Source

fn negate(&self) -> Self

Returns a negated integer, if integer is signed.

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 Integer for i8

Source§

const ZERO: Self = 0i8

Source§

const ONE: Self = 1i8

Source§

const TWO: Self = 2i8

Source§

const MIN: Self = -128i8

Source§

const MAX: Self = 127i8

Source§

const MAX_U64: u64 = 127u64

Source§

const N_BITS: usize = 8usize

Source§

const N_BITS_U64: u64 = 8u64

Source§

const SIGNED: bool = true

Source§

impl Integer for i16

Source§

const ZERO: Self = 0i16

Source§

const ONE: Self = 1i16

Source§

const TWO: Self = 2i16

Source§

const MIN: Self = -32_768i16

Source§

const MAX: Self = 32_767i16

Source§

const MAX_U64: u64 = 32_767u64

Source§

const N_BITS: usize = 16usize

Source§

const N_BITS_U64: u64 = 16u64

Source§

const SIGNED: bool = true

Source§

impl Integer for i32

Source§

const ZERO: Self = 0i32

Source§

const ONE: Self = 1i32

Source§

const TWO: Self = 2i32

Source§

const MIN: Self = -2_147_483_648i32

Source§

const MAX: Self = 2_147_483_647i32

Source§

const MAX_U64: u64 = 2_147_483_647u64

Source§

const N_BITS: usize = 32usize

Source§

const N_BITS_U64: u64 = 32u64

Source§

const SIGNED: bool = true

Source§

impl Integer for i64

Source§

const ZERO: Self = 0i64

Source§

const ONE: Self = 1i64

Source§

const TWO: Self = 2i64

Source§

const MIN: Self = -9_223_372_036_854_775_808i64

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

const MAX_U64: u64 = 9_223_372_036_854_775_807u64

Source§

const N_BITS: usize = 64usize

Source§

const N_BITS_U64: u64 = 64u64

Source§

const SIGNED: bool = true

Source§

impl Integer for i128

Source§

const ZERO: Self = 0i128

Source§

const ONE: Self = 1i128

Source§

const TWO: Self = 2i128

Source§

const MIN: Self = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

Source§

const MAX: Self = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

Source§

const MAX_U64: u64 = 18_446_744_073_709_551_615u64

Source§

const N_BITS: usize = 128usize

Source§

const N_BITS_U64: u64 = 128u64

Source§

const SIGNED: bool = true

Source§

impl Integer for isize

Source§

const ZERO: Self = 0isize

Source§

const ONE: Self = 1isize

Source§

const TWO: Self = 2isize

Source§

const MIN: Self = -9_223_372_036_854_775_808isize

Source§

const MAX: Self = 9_223_372_036_854_775_807isize

Source§

const MAX_U64: u64 = 9_223_372_036_854_775_807u64

Source§

const N_BITS: usize = 64usize

Source§

const N_BITS_U64: u64 = 64u64

Source§

const SIGNED: bool = true

Source§

impl Integer for u8

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

const TWO: Self = 2u8

Source§

const MIN: Self = 0u8

Source§

const MAX: Self = 255u8

Source§

const MAX_U64: u64 = 255u64

Source§

const N_BITS: usize = 8usize

Source§

const N_BITS_U64: u64 = 8u64

Source§

const SIGNED: bool = false

Source§

impl Integer for u16

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

const TWO: Self = 2u16

Source§

const MIN: Self = 0u16

Source§

const MAX: Self = 65_535u16

Source§

const MAX_U64: u64 = 65_535u64

Source§

const N_BITS: usize = 16usize

Source§

const N_BITS_U64: u64 = 16u64

Source§

const SIGNED: bool = false

Source§

impl Integer for u32

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

const TWO: Self = 2u32

Source§

const MIN: Self = 0u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

const MAX_U64: u64 = 4_294_967_295u64

Source§

const N_BITS: usize = 32usize

Source§

const N_BITS_U64: u64 = 32u64

Source§

const SIGNED: bool = false

Source§

impl Integer for u64

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

const TWO: Self = 2u64

Source§

const MIN: Self = 0u64

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

const MAX_U64: u64 = 18_446_744_073_709_551_615u64

Source§

const N_BITS: usize = 64usize

Source§

const N_BITS_U64: u64 = 64u64

Source§

const SIGNED: bool = false

Source§

impl Integer for u128

Source§

const ZERO: Self = 0u128

Source§

const ONE: Self = 1u128

Source§

const TWO: Self = 2u128

Source§

const MIN: Self = 0u128

Source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

const MAX_U64: u64 = 18_446_744_073_709_551_615u64

Source§

const N_BITS: usize = 128usize

Source§

const N_BITS_U64: u64 = 128u64

Source§

const SIGNED: bool = false

Source§

impl Integer for usize

Source§

const ZERO: Self = 0usize

Source§

const ONE: Self = 1usize

Source§

const TWO: Self = 2usize

Source§

const MIN: Self = 0usize

Source§

const MAX: Self = 18_446_744_073_709_551_615usize

Source§

const MAX_U64: u64 = 18_446_744_073_709_551_615u64

Source§

const N_BITS: usize = 64usize

Source§

const N_BITS_U64: u64 = 64u64

Source§

const SIGNED: bool = false

Implementors§