Skip to main content

Word

Trait Word 

Source
pub trait Word:
    Sealed
    + Copy
    + Default
    + Eq
    + Ord
    + Hash
    + Debug
    + Send
    + Sync
    + 'static
    + BitAnd<Output = Self>
    + BitOr<Output = Self>
    + BitXor<Output = Self>
    + Not<Output = Self>
    + Shl<usize, Output = Self>
    + Shr<usize, Output = Self> {
    const BITS: usize;
    const ZERO: Self;
    const ONES: Self;

    // Required methods
    fn count_ones(self) -> u32;
    fn to_u64(self) -> u64;
    fn from_u64(value: u64) -> Self;
}
Expand description

The machine integer a bit kernel shifts and masks.

Every operation inside a word goes through this, so a kernel is written once per shape.

Required Associated Constants§

Source

const BITS: usize

Bits in the word.

Source

const ZERO: Self

Every bit clear.

Source

const ONES: Self

Every bit set.

Required Methods§

Source

fn count_ones(self) -> u32

How many bits are set.

Source

fn to_u64(self) -> u64

The word widened to 64 bits, zero extended.

Source

fn from_u64(value: u64) -> Self

The low bits of a 64-bit value, with anything above the word’s width dropped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Word for u8

Source§

const BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u8::MAX

Source§

fn count_ones(self) -> u32

Source§

fn to_u64(self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl Word for u16

Source§

const BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u16::MAX

Source§

fn count_ones(self) -> u32

Source§

fn to_u64(self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl Word for u32

Source§

const BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u32::MAX

Source§

fn count_ones(self) -> u32

Source§

fn to_u64(self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl Word for u64

Source§

const BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u64::MAX

Source§

fn count_ones(self) -> u32

Source§

fn to_u64(self) -> u64

Source§

fn from_u64(value: u64) -> Self

Implementors§