Skip to main content

Underlier

Trait Underlier 

Source
pub unsafe trait Underlier:
    Copy
    + Default
    + Eq
    + Hash
    + Debug
    + Send
    + Sync
    + 'static {
    type Word: Word;

    const WORDS: usize;
    const ZERO: Self;
    const ONES: Self;
    const BITS: usize = _;

    // Required methods
    fn words(&self) -> &[Self::Word];
    fn words_mut(&mut self) -> &mut [Self::Word];
    fn from_words_fn(f: impl FnMut(usize) -> Self::Word) -> Self;
    fn random<R: Rng + ?Sized>(rng: &mut R) -> Self;

    // Provided method
    fn zip(
        self,
        other: Self,
        op: impl Fn(Self::Word, Self::Word) -> Self::Word,
    ) -> Self { ... }
}
Expand description

A fixed-width block of bits, addressed as an array of words.

Word 0 holds the lowest bits of the block, and bit 0 of a word is the lowest of all.

§Safety

A value must be exactly its words and nothing else:

  • its size must equal the word count times the size of one word,
  • its alignment must be at least a word’s.

Reinterpreting a run of values as a run of words relies on both.

Required Associated Constants§

Source

const WORDS: usize

How many words make up the block.

Source

const ZERO: Self

Every bit clear.

Source

const ONES: Self

Every bit set.

Provided Associated Constants§

Source

const BITS: usize = _

Bits in the whole block.

Required Associated Types§

Source

type Word: Word

The word the block is addressed in.

Required Methods§

Source

fn words(&self) -> &[Self::Word]

The words of the block, lowest bits first.

Source

fn words_mut(&mut self) -> &mut [Self::Word]

The words of the block, lowest bits first.

Source

fn from_words_fn(f: impl FnMut(usize) -> Self::Word) -> Self

Build a block word by word, lowest bits first.

Source

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

A block whose bits are uniformly random and independent.

Provided Methods§

Source

fn zip( self, other: Self, op: impl Fn(Self::Word, Self::Word) -> Self::Word, ) -> Self

Combine two blocks word by word.

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

Source§

const WORDS: usize = 1

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u8::MAX

Source§

type Word = u8

Source§

fn words(&self) -> &[Self::Word]

Source§

fn words_mut(&mut self) -> &mut [Self::Word]

Source§

fn from_words_fn(f: impl FnMut(usize) -> Self::Word) -> Self

Source§

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

Source§

impl Underlier for u16

Source§

const WORDS: usize = 1

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u16::MAX

Source§

type Word = u16

Source§

fn words(&self) -> &[Self::Word]

Source§

fn words_mut(&mut self) -> &mut [Self::Word]

Source§

fn from_words_fn(f: impl FnMut(usize) -> Self::Word) -> Self

Source§

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

Source§

impl Underlier for u32

Source§

const WORDS: usize = 1

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u32::MAX

Source§

type Word = u32

Source§

fn words(&self) -> &[Self::Word]

Source§

fn words_mut(&mut self) -> &mut [Self::Word]

Source§

fn from_words_fn(f: impl FnMut(usize) -> Self::Word) -> Self

Source§

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

Source§

impl Underlier for u64

Source§

const WORDS: usize = 1

Source§

const ZERO: Self = 0

Source§

const ONES: Self = u64::MAX

Source§

type Word = u64

Source§

fn words(&self) -> &[Self::Word]

Source§

fn words_mut(&mut self) -> &mut [Self::Word]

Source§

fn from_words_fn(f: impl FnMut(usize) -> Self::Word) -> Self

Source§

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

Implementors§

Source§

impl Underlier for M128

Source§

const WORDS: usize = 2

Source§

const ZERO: Self

Source§

const ONES: Self

Source§

type Word = u64

Source§

impl Underlier for M256

Source§

const WORDS: usize = 4

Source§

const ZERO: Self

Source§

const ONES: Self

Source§

type Word = u64

Source§

impl Underlier for M512

Source§

const WORDS: usize = 8

Source§

const ZERO: Self

Source§

const ONES: Self

Source§

type Word = u64