Integer

Trait Integer 

Source
pub trait Integer:
    Sized
    + Copy
    + Debug
    + Ord
    + BitOr<Output = Self> {
    type Bytes: Copy + Default + AsMut<[u8]> + AsRef<[u8]>;

    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;

    // Required methods
    fn from_bytes(bytes: Self::Bytes) -> Self;
    fn is_even(self) -> bool;
    fn add(self, rhs: Self) -> Self;
    fn sub(self, rhs: Self) -> Self;
    fn mul(self, rhs: Self) -> Self;
    fn div(self, rhs: Self) -> Self;
    fn neg(self) -> Self;
}

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Required Associated Types§

Source

type Bytes: Copy + Default + AsMut<[u8]> + AsRef<[u8]>

Required Methods§

Source

fn from_bytes(bytes: Self::Bytes) -> Self

Source

fn is_even(self) -> bool

Source

fn add(self, rhs: Self) -> Self

Source

fn sub(self, rhs: Self) -> Self

Source

fn mul(self, rhs: Self) -> Self

Source

fn div(self, rhs: Self) -> Self

Source

fn neg(self) -> Self

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 Integer for u8

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

const TWO: Self = 2u8

Source§

type Bytes = [u8; 1]

Source§

fn from_bytes(bytes: Self::Bytes) -> Self

Source§

fn is_even(self) -> bool

Source§

fn add(self, rhs: Self) -> Self

Source§

fn sub(self, rhs: Self) -> Self

Source§

fn mul(self, rhs: Self) -> Self

Source§

fn div(self, rhs: Self) -> Self

Source§

fn neg(self) -> Self

Source§

impl Integer for u16

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

const TWO: Self = 2u16

Source§

type Bytes = [u8; 2]

Source§

fn from_bytes(bytes: Self::Bytes) -> Self

Source§

fn is_even(self) -> bool

Source§

fn add(self, rhs: Self) -> Self

Source§

fn sub(self, rhs: Self) -> Self

Source§

fn mul(self, rhs: Self) -> Self

Source§

fn div(self, rhs: Self) -> Self

Source§

fn neg(self) -> Self

Source§

impl Integer for u32

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

const TWO: Self = 2u32

Source§

type Bytes = [u8; 4]

Source§

fn from_bytes(bytes: Self::Bytes) -> Self

Source§

fn is_even(self) -> bool

Source§

fn add(self, rhs: Self) -> Self

Source§

fn sub(self, rhs: Self) -> Self

Source§

fn mul(self, rhs: Self) -> Self

Source§

fn div(self, rhs: Self) -> Self

Source§

fn neg(self) -> Self

Source§

impl Integer for u64

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

const TWO: Self = 2u64

Source§

type Bytes = [u8; 8]

Source§

fn from_bytes(bytes: Self::Bytes) -> Self

Source§

fn is_even(self) -> bool

Source§

fn add(self, rhs: Self) -> Self

Source§

fn sub(self, rhs: Self) -> Self

Source§

fn mul(self, rhs: Self) -> Self

Source§

fn div(self, rhs: Self) -> Self

Source§

fn neg(self) -> Self

Source§

impl Integer for u128

Source§

const ZERO: Self = 0u128

Source§

const ONE: Self = 1u128

Source§

const TWO: Self = 2u128

Source§

type Bytes = [u8; 16]

Source§

fn from_bytes(bytes: Self::Bytes) -> Self

Source§

fn is_even(self) -> bool

Source§

fn add(self, rhs: Self) -> Self

Source§

fn sub(self, rhs: Self) -> Self

Source§

fn mul(self, rhs: Self) -> Self

Source§

fn div(self, rhs: Self) -> Self

Source§

fn neg(self) -> Self

Source§

impl Integer for usize

Source§

const ZERO: Self = 0usize

Source§

const ONE: Self = 1usize

Source§

const TWO: Self = 2usize

Source§

type Bytes = [u8; 8]

Source§

fn from_bytes(bytes: Self::Bytes) -> Self

Source§

fn is_even(self) -> bool

Source§

fn add(self, rhs: Self) -> Self

Source§

fn sub(self, rhs: Self) -> Self

Source§

fn mul(self, rhs: Self) -> Self

Source§

fn div(self, rhs: Self) -> Self

Source§

fn neg(self) -> Self

Implementors§