[][src]Trait compiler_builtins::int::Int

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

Associated Types

type OtherSign: Int

Type with the same width but other signedness

type UnsignedInt: Int

Unsigned version of Self

Loading content...

Associated Constants

const BITS: u32

The bitwidth of the int type

const ZERO: Self

const ONE: Self

Loading content...

Required methods

fn extract_sign(self) -> (bool, Self::UnsignedInt)

Extracts the sign from self and returns a tuple.

Examples

This example is not tested
let i = -25_i32;
let (sign, u) = i.extract_sign();
assert_eq!(sign, true);
assert_eq!(u, 25_u32);

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

Loading content...

Implementors

impl Int for i32[src]

type OtherSign = u32

type UnsignedInt = u32

impl Int for i64[src]

type OtherSign = u64

type UnsignedInt = u64

impl Int for i128[src]

type OtherSign = u128

type UnsignedInt = u128

impl Int for u32[src]

type OtherSign = i32

type UnsignedInt = u32

impl Int for u64[src]

type OtherSign = i64

type UnsignedInt = u64

impl Int for u128[src]

type OtherSign = i128

type UnsignedInt = u128

Loading content...