Skip to main content

Integer

Trait Integer 

Source
pub trait Integer:
    Number
    + Not<Output = Self>
    + BitAnd<Output = Self>
    + BitAndAssign
    + BitOr<Output = Self>
    + BitOrAssign
    + BitXor<Output = Self>
    + BitXorAssign
    + Shl<Output = Self>
    + Shl<u32, Output = Self>
    + ShlAssign
    + ShlAssign<u32>
    + Shr<Output = Self>
    + Shr<u32, Output = Self>
    + ShrAssign
    + ShrAssign<u32>
    + TryInto<i128>
    + From<bool> {
    type NonZero: Copy + TryFrom<Self> + Into<Self>;
    type Unsigned: UnsignedInteger<Signed = Self::Signed>;
    type Signed: SignedInteger<Unsigned = Self::Unsigned>;

    const BITS: u32;

    // Required methods
    fn abs_diff(self, rhs: Self) -> Self::Unsigned;
    fn checked_add(self, rhs: Self) -> Option<Self>;
    fn checked_sub(self, rhs: Self) -> Option<Self>;
    fn checked_mul(self, rhs: Self) -> Option<Self>;
    fn isolate_lowest_one(self) -> Self;
    fn lowest_one(self) -> Option<u32>;
    fn trailing_ones(self) -> u32;
    fn trailing_zeros(self) -> u32;
    fn unsigned_abs(self) -> Self::Unsigned;
    fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned;
}
Expand description

Trait implemented by the primitive integer types.

Required Associated Constants§

Required Associated Types§

Source

type NonZero: Copy + TryFrom<Self> + Into<Self>

Source

type Unsigned: UnsignedInteger<Signed = Self::Signed>

Source

type Signed: SignedInteger<Unsigned = Self::Unsigned>

Required Methods§

Source

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source

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

Source

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

Source

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

Source

fn isolate_lowest_one(self) -> Self

Source

fn lowest_one(self) -> Option<u32>

Source

fn trailing_ones(self) -> u32

Source

fn trailing_zeros(self) -> u32

Source

fn unsigned_abs(self) -> Self::Unsigned

Source

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Integer for i8

Source§

const BITS: u32 = i8::BITS

Source§

type NonZero = NonZero<i8>

Source§

type Unsigned = u8

Source§

type Signed = i8

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for i16

Source§

const BITS: u32 = i16::BITS

Source§

type NonZero = NonZero<i16>

Source§

type Unsigned = u16

Source§

type Signed = i16

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for i32

Source§

const BITS: u32 = i32::BITS

Source§

type NonZero = NonZero<i32>

Source§

type Unsigned = u32

Source§

type Signed = i32

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for i64

Source§

const BITS: u32 = i64::BITS

Source§

type NonZero = NonZero<i64>

Source§

type Unsigned = u64

Source§

type Signed = i64

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for i128

Source§

const BITS: u32 = i128::BITS

Source§

type NonZero = NonZero<i128>

Source§

type Unsigned = u128

Source§

type Signed = i128

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for isize

Source§

const BITS: u32 = isize::BITS

Source§

type NonZero = NonZero<isize>

Source§

type Unsigned = usize

Source§

type Signed = isize

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for u8

Source§

const BITS: u32 = u8::BITS

Source§

type NonZero = NonZero<u8>

Source§

type Unsigned = u8

Source§

type Signed = i8

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for u16

Source§

const BITS: u32 = u16::BITS

Source§

type NonZero = NonZero<u16>

Source§

type Unsigned = u16

Source§

type Signed = i16

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for u32

Source§

const BITS: u32 = u32::BITS

Source§

type NonZero = NonZero<u32>

Source§

type Unsigned = u32

Source§

type Signed = i32

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for u64

Source§

const BITS: u32 = u64::BITS

Source§

type NonZero = NonZero<u64>

Source§

type Unsigned = u64

Source§

type Signed = i64

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for u128

Source§

const BITS: u32 = u128::BITS

Source§

type NonZero = NonZero<u128>

Source§

type Unsigned = u128

Source§

type Signed = i128

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Source§

impl Integer for usize

Source§

const BITS: u32 = usize::BITS

Source§

type NonZero = NonZero<usize>

Source§

type Unsigned = usize

Source§

type Signed = isize

Source§

fn abs_diff(self, rhs: Self) -> Self::Unsigned

Source§

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

Source§

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

Source§

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

Source§

fn isolate_lowest_one(self) -> Self

Source§

fn lowest_one(self) -> Option<u32>

Source§

fn trailing_ones(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn unsigned_abs(self) -> Self::Unsigned

Source§

fn saturating_sub_0(self, rhs: Self) -> Self::Unsigned

Implementors§