pub unsafe trait NonZeroBitArray: Copy + Display + Debug + Eq + Hash + 'static {
    type Base: BitArray<NonZero = Self>;

    // Required methods
    fn new(n: Self::Base) -> Option<Self>;
    unsafe fn new_unchecked(n: Self::Base) -> Self;
    fn get(self) -> Self::Base;
}
Expand description

A trait for bit strings like BitArray but with guaranteed nonzero values

Safety

Must guarantee that the value is indeed nonzero. Failing to do so could, e.g., cause a division by zero in entropy coders, which is undefined behavior.

Required Associated Types§

source

type Base: BitArray<NonZero = Self>

Required Methods§

source

fn new(n: Self::Base) -> Option<Self>

source

unsafe fn new_unchecked(n: Self::Base) -> Self

Safety

The provided value n must be nonzero.

source

fn get(self) -> Self::Base

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NonZeroBitArray for NonZeroU8

§

type Base = u8

source§

fn new(n: Self::Base) -> Option<Self>

source§

unsafe fn new_unchecked(n: Self::Base) -> Self

source§

fn get(self) -> Self::Base

source§

impl NonZeroBitArray for NonZeroU16

§

type Base = u16

source§

fn new(n: Self::Base) -> Option<Self>

source§

unsafe fn new_unchecked(n: Self::Base) -> Self

source§

fn get(self) -> Self::Base

source§

impl NonZeroBitArray for NonZeroU32

§

type Base = u32

source§

fn new(n: Self::Base) -> Option<Self>

source§

unsafe fn new_unchecked(n: Self::Base) -> Self

source§

fn get(self) -> Self::Base

source§

impl NonZeroBitArray for NonZeroU64

§

type Base = u64

source§

fn new(n: Self::Base) -> Option<Self>

source§

unsafe fn new_unchecked(n: Self::Base) -> Self

source§

fn get(self) -> Self::Base

source§

impl NonZeroBitArray for NonZeroU128

§

type Base = u128

source§

fn new(n: Self::Base) -> Option<Self>

source§

unsafe fn new_unchecked(n: Self::Base) -> Self

source§

fn get(self) -> Self::Base

source§

impl NonZeroBitArray for NonZeroUsize

§

type Base = usize

source§

fn new(n: Self::Base) -> Option<Self>

source§

unsafe fn new_unchecked(n: Self::Base) -> Self

source§

fn get(self) -> Self::Base

Implementors§