pub trait Int: Copy + PartialEq + PartialOrd + AddAssign + BitAndAssign + BitOrAssign + ShlAssign<i32> + ShrAssign<u32> + Add<Output = Self> + Sub<Output = Self> + Div<Output = Self> + Shl<u32, Output = Self> + Shr<u32, Output = Self> + BitOr<Output = Self> + BitXor<Output = Self> + BitAnd<Output = Self> + Not<Output = Self> {
type OtherSign: Int;
type UnsignedInt: Int;
const BITS: u32;
const ZERO: Self;
const ONE: Self;
fn extract_sign(self) -> (bool, Self::UnsignedInt);
fn unsigned(self) -> Self::UnsignedInt;
fn from_unsigned(unsigned: Self::UnsignedInt) -> Self;
fn from_bool(b: bool) -> Self;
fn max_value() -> Self;
fn min_value() -> 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 overflowing_add(self, other: Self) -> (Self, bool);
fn aborting_div(self, other: Self) -> Self;
fn aborting_rem(self, other: Self) -> Self;
fn leading_zeros(self) -> u32;
}
Trait for some basic operations on integers
Type with the same width but other signedness
Loading content...
const BITS: u32
The bitwidth of the int type
const ZERO: Self
const ONE: Self
Loading content...
Extracts the sign from self and returns a tuple.
let i = -25_i32;
let (sign, u) = i.extract_sign();
assert_eq!(sign, true);
assert_eq!(u, 25_u32);
fn from_bool(b: bool) -> 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 overflowing_add(self, other: Self) -> (Self, bool)
fn aborting_div(self, other: Self) -> Self
fn aborting_rem(self, other: Self) -> Self
Loading content...
Loading content...