NonZeroBitArray

Trait NonZeroBitArray 

Source
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

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 NonZeroBitArray for NonZeroU8

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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§