Integer

Trait Integer 

Source
pub trait Integer:
    Number
    + Eq
    + Ord
    + BitAnd<Output = Self>
    + BitAndAssign
    + BitOr<Output = Self>
    + BitOrAssign
    + BitXor<Output = Self>
    + BitXorAssign
    + Not<Output = Self>
    + Shl<Self, Output = Self>
    + Shl<i32, Output = Self>
    + ShlAssign<i32>
    + Shr<i32, Output = Self>
    + ShrAssign<i32> {
    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;
    const MAX: Self;
    const MIN: Self;
    const BITS: usize;
Show 21 methods // Required methods fn leading_zeros(self) -> u32; fn trailing_zeros(self) -> u32; fn pow(self, exp: u32) -> Self; fn checked_add(self, i: Self) -> Option<Self>; fn checked_sub(self, i: Self) -> Option<Self>; fn checked_mul(self, i: Self) -> Option<Self>; fn overflowing_add(self, i: Self) -> (Self, bool); fn overflowing_mul(self, i: Self) -> (Self, bool); fn wrapping_add(self, i: Self) -> Self; fn wrapping_sub(self, i: Self) -> Self; fn wrapping_mul(self, i: Self) -> Self; fn wrapping_neg(self) -> Self; fn saturating_add(self, i: Self) -> Self; fn saturating_sub(self, i: Self) -> Self; fn saturating_mul(self, i: Self) -> Self; // Provided methods fn ceil_divmod(self, y: Self) -> (Self, i32) { ... } fn ceil_div(self, y: Self) -> Self { ... } fn ceil_mod(self, y: Self) -> i32 { ... } fn bit_length(self) -> u32 { ... } fn is_odd(self) -> bool { ... } fn is_even(self) -> bool { ... }
}
Expand description

Defines a trait that supports integral operations.

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Source

const MAX: Self

Source

const MIN: Self

Source

const BITS: usize

Required Methods§

Source

fn leading_zeros(self) -> u32

Source

fn trailing_zeros(self) -> u32

Source

fn pow(self, exp: u32) -> Self

Source

fn checked_add(self, i: Self) -> Option<Self>

Source

fn checked_sub(self, i: Self) -> Option<Self>

Source

fn checked_mul(self, i: Self) -> Option<Self>

Source

fn overflowing_add(self, i: Self) -> (Self, bool)

Source

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source

fn wrapping_add(self, i: Self) -> Self

Source

fn wrapping_sub(self, i: Self) -> Self

Source

fn wrapping_mul(self, i: Self) -> Self

Source

fn wrapping_neg(self) -> Self

Source

fn saturating_add(self, i: Self) -> Self

Source

fn saturating_sub(self, i: Self) -> Self

Source

fn saturating_mul(self, i: Self) -> Self

Provided Methods§

Source

fn ceil_divmod(self, y: Self) -> (Self, i32)

Get the fast ceiling of the quotient from integer division. Not safe, since the remainder can easily overflow.

Source

fn ceil_div(self, y: Self) -> Self

Get the fast ceiling of the quotient from integer division. Not safe, since the remainder can easily overflow.

Source

fn ceil_mod(self, y: Self) -> i32

Get the fast ceiling modulus from integer division. Not safe, since the remainder can easily overflow.

Source

fn bit_length(self) -> u32

Get the number of bits in a value.

Source

fn is_odd(self) -> bool

Returns true if the least-significant bit is odd.

Source

fn is_even(self) -> bool

Returns true if the least-significant bit is even.

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: i8 = 0

Source§

const ONE: i8 = 1

Source§

const TWO: i8 = 2

Source§

const MAX: i8

Source§

const MIN: i8

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for i16

Source§

const ZERO: i16 = 0

Source§

const ONE: i16 = 1

Source§

const TWO: i16 = 2

Source§

const MAX: i16

Source§

const MIN: i16

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for i32

Source§

const ZERO: i32 = 0

Source§

const ONE: i32 = 1

Source§

const TWO: i32 = 2

Source§

const MAX: i32

Source§

const MIN: i32

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for i64

Source§

const ZERO: i64 = 0

Source§

const ONE: i64 = 1

Source§

const TWO: i64 = 2

Source§

const MAX: i64

Source§

const MIN: i64

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for i128

Source§

const ZERO: i128 = 0

Source§

const ONE: i128 = 1

Source§

const TWO: i128 = 2

Source§

const MAX: i128

Source§

const MIN: i128

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for isize

Source§

const ZERO: isize = 0

Source§

const ONE: isize = 1

Source§

const TWO: isize = 2

Source§

const MAX: isize

Source§

const MIN: isize

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for u8

Source§

const ZERO: u8 = 0

Source§

const ONE: u8 = 1

Source§

const TWO: u8 = 2

Source§

const MAX: u8

Source§

const MIN: u8

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for u16

Source§

const ZERO: u16 = 0

Source§

const ONE: u16 = 1

Source§

const TWO: u16 = 2

Source§

const MAX: u16

Source§

const MIN: u16

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for u32

Source§

const ZERO: u32 = 0

Source§

const ONE: u32 = 1

Source§

const TWO: u32 = 2

Source§

const MAX: u32

Source§

const MIN: u32

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for u64

Source§

const ZERO: u64 = 0

Source§

const ONE: u64 = 1

Source§

const TWO: u64 = 2

Source§

const MAX: u64

Source§

const MIN: u64

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for u128

Source§

const ZERO: u128 = 0

Source§

const ONE: u128 = 1

Source§

const TWO: u128 = 2

Source§

const MAX: u128

Source§

const MIN: u128

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Source§

impl Integer for usize

Source§

const ZERO: usize = 0

Source§

const ONE: usize = 1

Source§

const TWO: usize = 2

Source§

const MAX: usize

Source§

const MIN: usize

Source§

const BITS: usize

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn checked_add(self, i: Self) -> Option<Self>

Source§

fn checked_sub(self, i: Self) -> Option<Self>

Source§

fn checked_mul(self, i: Self) -> Option<Self>

Source§

fn overflowing_add(self, i: Self) -> (Self, bool)

Source§

fn overflowing_mul(self, i: Self) -> (Self, bool)

Source§

fn wrapping_add(self, i: Self) -> Self

Source§

fn wrapping_sub(self, i: Self) -> Self

Source§

fn wrapping_mul(self, i: Self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

fn saturating_add(self, i: Self) -> Self

Source§

fn saturating_sub(self, i: Self) -> Self

Source§

fn saturating_mul(self, i: Self) -> Self

Implementors§