Trait lexical_util::num::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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Integer for i8

source§

const ZERO: i8 = 0i8

source§

const ONE: i8 = 1i8

source§

const TWO: i8 = 2i8

source§

const MAX: i8 = 127i8

source§

const MIN: i8 = -128i8

source§

const BITS: usize = 8usize

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 = 0i16

source§

const ONE: i16 = 1i16

source§

const TWO: i16 = 2i16

source§

const MAX: i16 = 32_767i16

source§

const MIN: i16 = -32_768i16

source§

const BITS: usize = 16usize

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 = 0i32

source§

const ONE: i32 = 1i32

source§

const TWO: i32 = 2i32

source§

const MAX: i32 = 2_147_483_647i32

source§

const MIN: i32 = -2_147_483_648i32

source§

const BITS: usize = 32usize

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 = 0i64

source§

const ONE: i64 = 1i64

source§

const TWO: i64 = 2i64

source§

const MAX: i64 = 9_223_372_036_854_775_807i64

source§

const MIN: i64 = -9_223_372_036_854_775_808i64

source§

const BITS: usize = 64usize

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 = 0i128

source§

const ONE: i128 = 1i128

source§

const TWO: i128 = 2i128

source§

const MAX: i128 = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

source§

const MIN: i128 = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

source§

const BITS: usize = 128usize

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 = 0isize

source§

const ONE: isize = 1isize

source§

const TWO: isize = 2isize

source§

const MAX: isize = 9_223_372_036_854_775_807isize

source§

const MIN: isize = -9_223_372_036_854_775_808isize

source§

const BITS: usize = 64usize

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 = 0u8

source§

const ONE: u8 = 1u8

source§

const TWO: u8 = 2u8

source§

const MAX: u8 = 255u8

source§

const MIN: u8 = 0u8

source§

const BITS: usize = 8usize

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 = 0u16

source§

const ONE: u16 = 1u16

source§

const TWO: u16 = 2u16

source§

const MAX: u16 = 65_535u16

source§

const MIN: u16 = 0u16

source§

const BITS: usize = 16usize

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 = 0u32

source§

const ONE: u32 = 1u32

source§

const TWO: u32 = 2u32

source§

const MAX: u32 = 4_294_967_295u32

source§

const MIN: u32 = 0u32

source§

const BITS: usize = 32usize

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 = 0u64

source§

const ONE: u64 = 1u64

source§

const TWO: u64 = 2u64

source§

const MAX: u64 = 18_446_744_073_709_551_615u64

source§

const MIN: u64 = 0u64

source§

const BITS: usize = 64usize

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 = 0u128

source§

const ONE: u128 = 1u128

source§

const TWO: u128 = 2u128

source§

const MAX: u128 = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

source§

const MIN: u128 = 0u128

source§

const BITS: usize = 128usize

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 = 0usize

source§

const ONE: usize = 1usize

source§

const TWO: usize = 2usize

source§

const MAX: usize = 18_446_744_073_709_551_615usize

source§

const MIN: usize = 0usize

source§

const BITS: usize = 64usize

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§