Trait Size

Source
pub trait Size<const D: usize>: PrimInt {
    type Output: PrimInt;

    // Required methods
    fn expand(self) -> <Self as Size<D>>::Output;
    fn compress(output: <Self as Size<D>>::Output) -> Self;
}
Expand description

Trait to help with generic interleaving of bits.

Required Associated Types§

Source

type Output: PrimInt

The resulting type when expanding Self.

Required Methods§

Source

fn expand(self) -> <Self as Size<D>>::Output

Expand a value by shifting its bits.

The original value’s bits are moved to every Dth position, with 0s filling the gaps.

Source

fn compress(output: <Self as Size<D>>::Output) -> Self

The inverse of expand.

The expanded bits are moved back to their original positions.

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 Size<2> for u8

Source§

impl Size<2> for u16

Source§

impl Size<2> for u32

Source§

impl Size<2> for u64

Source§

impl Size<3> for u8

Source§

impl Size<3> for u16

Source§

impl Size<3> for u32

Source§

impl Size<4> for u8

Source§

impl Size<4> for u16

Source§

type Output = u64

Source§

fn expand(self) -> <Self as Size<4>>::Output

Source§

fn compress(val: u64) -> u16

Source§

impl Size<4> for u32

Source§

impl Size<5> for u8

Source§

impl Size<5> for u16

Source§

type Output = u128

Source§

fn expand(self) -> <Self as Size<5>>::Output

Source§

fn compress(val: u128) -> u16

Source§

impl Size<6> for u8

Source§

impl Size<6> for u16

Source§

impl Size<7> for u8

Source§

impl Size<7> for u16

Source§

impl Size<8> for u8

Source§

impl Size<8> for u16

Source§

impl Size<9> for u8

Source§

impl Size<10> for u8

Source§

impl Size<11> for u8

Source§

impl Size<12> for u8

Source§

impl Size<13> for u8

Source§

impl Size<14> for u8

Source§

impl Size<15> for u8

Source§

impl Size<16> for u8

Implementors§