Trait Int

Source
pub trait Int:
    MinInt
    + Display
    + Binary
    + LowerHex
    + PartialEq
    + PartialOrd
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + RemAssign
    + BitAndAssign
    + BitOrAssign
    + BitXorAssign
    + ShlAssign<i32>
    + ShlAssign<u32>
    + ShrAssign<u32>
    + ShrAssign<i32>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Rem<Output = Self>
    + Shl<i32, Output = Self>
    + Shl<u32, Output = Self>
    + Shr<i32, Output = Self>
    + Shr<u32, Output = Self>
    + BitXor<Output = Self>
    + BitAnd<Output = Self>
    + Ord
    + From<bool>
    + CastFrom<i32>
    + CastFrom<u16>
    + CastFrom<u32>
    + CastFrom<u8>
    + CastFrom<usize>
    + CastInto<i32>
    + CastInto<u16>
    + CastInto<u32>
    + CastInto<u8>
    + CastInto<usize> {
Show 21 methods // Required methods fn signed(self) -> <Self::Unsigned as MinInt>::OtherSign; fn unsigned(self) -> Self::Unsigned; fn from_unsigned(unsigned: Self::Unsigned) -> Self; fn abs(self) -> Self; fn from_bool(b: bool) -> Self; fn logical_shr(self, other: u32) -> Self; fn abs_diff(self, other: Self) -> Self::Unsigned; fn is_zero(self) -> bool; fn checked_add(self, other: Self) -> Option<Self>; fn checked_sub(self, other: Self) -> Option<Self>; fn wrapping_neg(self) -> Self; fn wrapping_add(self, other: Self) -> Self; fn wrapping_mul(self, other: Self) -> Self; fn wrapping_sub(self, other: Self) -> Self; fn wrapping_shl(self, other: u32) -> Self; fn wrapping_shr(self, other: u32) -> Self; fn rotate_left(self, other: u32) -> Self; fn overflowing_add(self, other: Self) -> (Self, bool); fn overflowing_sub(self, other: Self) -> (Self, bool); fn leading_zeros(self) -> u32; fn ilog2(self) -> u32;
}
Expand description

Trait for some basic operations on integers

Required Methods§

Source

fn signed(self) -> <Self::Unsigned as MinInt>::OtherSign

Source

fn unsigned(self) -> Self::Unsigned

Source

fn from_unsigned(unsigned: Self::Unsigned) -> Self

Source

fn abs(self) -> Self

Source

fn from_bool(b: bool) -> Self

Source

fn logical_shr(self, other: u32) -> Self

Prevents the need for excessive conversions between signed and unsigned

Source

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

Absolute difference between two integers.

Source

fn is_zero(self) -> bool

Source

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

Source

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

Source

fn wrapping_neg(self) -> Self

Source

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

Source

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

Source

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

Source

fn wrapping_shl(self, other: u32) -> Self

Source

fn wrapping_shr(self, other: u32) -> Self

Source

fn rotate_left(self, other: u32) -> Self

Source

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

Source

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source

fn leading_zeros(self) -> u32

Source

fn ilog2(self) -> u32

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

Source§

fn signed(self) -> Self

Source§

fn unsigned(self) -> u8

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u8) -> Self

Source§

fn abs_diff(self, other: Self) -> u8

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for i16

Source§

fn signed(self) -> Self

Source§

fn unsigned(self) -> u16

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u16) -> Self

Source§

fn abs_diff(self, other: Self) -> u16

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for i32

Source§

fn signed(self) -> Self

Source§

fn unsigned(self) -> u32

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u32) -> Self

Source§

fn abs_diff(self, other: Self) -> u32

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for i64

Source§

fn signed(self) -> Self

Source§

fn unsigned(self) -> u64

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u64) -> Self

Source§

fn abs_diff(self, other: Self) -> u64

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for i128

Source§

fn signed(self) -> Self

Source§

fn unsigned(self) -> u128

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u128) -> Self

Source§

fn abs_diff(self, other: Self) -> u128

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for isize

Source§

fn signed(self) -> Self

Source§

fn unsigned(self) -> usize

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: usize) -> Self

Source§

fn abs_diff(self, other: Self) -> usize

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for u8

Source§

fn signed(self) -> i8

Source§

fn unsigned(self) -> Self

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u8) -> Self

Source§

fn abs_diff(self, other: Self) -> Self

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for u16

Source§

fn signed(self) -> i16

Source§

fn unsigned(self) -> Self

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u16) -> Self

Source§

fn abs_diff(self, other: Self) -> Self

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for u32

Source§

fn signed(self) -> i32

Source§

fn unsigned(self) -> Self

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u32) -> Self

Source§

fn abs_diff(self, other: Self) -> Self

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for u64

Source§

fn signed(self) -> i64

Source§

fn unsigned(self) -> Self

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u64) -> Self

Source§

fn abs_diff(self, other: Self) -> Self

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for u128

Source§

fn signed(self) -> i128

Source§

fn unsigned(self) -> Self

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: u128) -> Self

Source§

fn abs_diff(self, other: Self) -> Self

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Source§

impl Int for usize

Source§

fn signed(self) -> isize

Source§

fn unsigned(self) -> Self

Source§

fn abs(self) -> Self

Source§

fn from_unsigned(me: usize) -> Self

Source§

fn abs_diff(self, other: Self) -> Self

Source§

fn from_bool(b: bool) -> Self

Source§

fn logical_shr(self, other: u32) -> Self

Source§

fn is_zero(self) -> bool

Source§

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

Source§

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

Source§

fn wrapping_neg(self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn wrapping_shl(self, other: u32) -> Self

Source§

fn wrapping_shr(self, other: u32) -> Self

Source§

fn rotate_left(self, other: u32) -> Self

Source§

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

Source§

fn overflowing_sub(self, other: Self) -> (Self, bool)

Source§

fn leading_zeros(self) -> u32

Source§

fn ilog2(self) -> u32

Implementors§