pub unsafe trait BitArray: PrimInt + Unsigned + WrappingAdd + WrappingSub + WrappingMul + LowerHex + UpperHex + Binary + Default + Copy + Display + Debug + Eq + Hash + 'static {
    type NonZero: NonZeroBitArray<Base = Self>;

    const BITS: usize = _;

    // Provided methods
    fn into_nonzero(self) -> Option<Self::NonZero> { ... }
    unsafe fn into_nonzero_unchecked(self) -> Self::NonZero { ... }
}
Expand description

A trait for bit strings of fixed (and usually small) length.

Short fixed-length bit strings are fundamental building blocks of efficient entropy coding algorithms. They are currently used for the following purposes:

This trait is implemented on all primitive unsigned integer types. It is not recommended to implement this trait for custom types since coders will assume, for performance considerations, that BitArrays can be represented and manipulated efficiently in hardware.

Safety

This trait is marked unsafe so that entropy coders may rely on the assumption that all BitArrays have precisely the same behavior as builtin unsigned integer types, and that BitArray::BITS has the correct value.

Required Associated Types§

source

type NonZero: NonZeroBitArray<Base = Self>

Provided Associated Constants§

source

const BITS: usize = _

The (fixed) length of the BitArray in bits.

Defaults to 8 * core::mem::size_of::<Self>(), which is suitable for all primitive unsigned integers.

This could arguably be called LEN instead, but that may be confusing since “lengths” are typically not measured in bits in the Rust ecosystem.

Provided Methods§

source

fn into_nonzero(self) -> Option<Self::NonZero>

source

unsafe fn into_nonzero_unchecked(self) -> Self::NonZero

Safety

The provided value must be nonzero.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BitArray for u8

source§

impl BitArray for u16

source§

impl BitArray for u32

source§

impl BitArray for u64

source§

impl BitArray for u128

source§

impl BitArray for usize

Implementors§