arithmetic_coding_core/
bitstore.rsuse std::ops::{Add, AddAssign, Div, Mul, Shl, ShlAssign, Sub};
pub trait BitStore:
Shl<u32, Output = Self>
+ ShlAssign<u32>
+ Sub<Output = Self>
+ Add<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ AddAssign
+ PartialOrd
+ Copy
+ std::fmt::Debug
{
const BITS: u32;
const ZERO: Self;
const ONE: Self;
fn log2(self) -> u32;
}
macro_rules! impl_bitstore {
($t:ty) => {
impl BitStore for $t {
const BITS: u32 = Self::BITS;
const ONE: Self = 1;
const ZERO: Self = 0;
fn log2(self) -> u32 {
Self::ilog2(self)
}
}
};
}
impl_bitstore! {u32}
impl_bitstore! {u64}
impl_bitstore! {u128}
impl_bitstore! {usize}