Number

Trait Number 

Source
pub trait Number:
    Copy
    + Add<Self, Output = Self>
    + Sub<Self, Output = Self>
    + Shl<usize, Output = Self>
    + Shr<usize, Output = Self>
    + Not<Output = Self>
    + BitAnd<Self, Output = Self>
    + BitOr<Self, Output = Self>
    + Eq
    + Ord
    + Binary {
    const BITS_COUNT: usize;
    const BYTES_COUNT: usize;
    const ONE: Self;
    const ZERO: Self;
    const MAX: Self;
    const MIN: Self;
    const BYTE_MASK: Self;

    // Required methods
    fn count_ones(self) -> u32;
    fn count_zeros(self) -> u32;
}

Required Associated Constants§

Source

const BITS_COUNT: usize

Source

const BYTES_COUNT: usize

Source

const ONE: Self

Source

const ZERO: Self

Source

const MAX: Self

Source

const MIN: Self

Source

const BYTE_MASK: Self

Required Methods§

Source

fn count_ones(self) -> u32

Source

fn count_zeros(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 Number for u8

Source§

const BITS_COUNT: usize = 8usize

Source§

const BYTES_COUNT: usize = 1usize

Source§

const ONE: Self = 1u8

Source§

const ZERO: Self = 0u8

Source§

const MAX: Self = 255u8

Source§

const MIN: Self = 0u8

Source§

const BYTE_MASK: Self = 255u8

Source§

fn count_ones(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

impl Number for u16

Source§

const BITS_COUNT: usize = 16usize

Source§

const BYTES_COUNT: usize = 2usize

Source§

const ONE: Self = 1u16

Source§

const ZERO: Self = 0u16

Source§

const MAX: Self = 65_535u16

Source§

const MIN: Self = 0u16

Source§

const BYTE_MASK: Self = 255u16

Source§

fn count_ones(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

impl Number for u32

Source§

const BITS_COUNT: usize = 32usize

Source§

const BYTES_COUNT: usize = 4usize

Source§

const ONE: Self = 1u32

Source§

const ZERO: Self = 0u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

const MIN: Self = 0u32

Source§

const BYTE_MASK: Self = 255u32

Source§

fn count_ones(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

impl Number for u64

Source§

const BITS_COUNT: usize = 64usize

Source§

const BYTES_COUNT: usize = 8usize

Source§

const ONE: Self = 1u64

Source§

const ZERO: Self = 0u64

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

const MIN: Self = 0u64

Source§

const BYTE_MASK: Self = 255u64

Source§

fn count_ones(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

impl Number for u128

Source§

const BITS_COUNT: usize = 128usize

Source§

const BYTES_COUNT: usize = 16usize

Source§

const ONE: Self = 1u128

Source§

const ZERO: Self = 0u128

Source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

const MIN: Self = 0u128

Source§

const BYTE_MASK: Self = 255u128

Source§

fn count_ones(self) -> u32

Source§

fn count_zeros(self) -> u32

Implementors§