arithmetic_coding_core_adder_dep/
bitstore.rs1use std::ops::{Add, AddAssign, Div, Mul, Shl, ShlAssign, Sub};
2
3pub trait BitStore:
6 Shl<u32, Output = Self>
7 + ShlAssign<u32>
8 + Sized
9 + From<u32>
10 + Sub<Output = Self>
11 + Add<Output = Self>
12 + Mul<Output = Self>
13 + Div<Output = Self>
14 + AddAssign
15 + PartialOrd
16 + Copy
17 + std::fmt::Debug
18{
19 const BITS: u32;
21
22 const ZERO: Self;
24
25 const ONE: Self;
27
28 fn log2(self) -> u32;
30}
31
32macro_rules! impl_bitstore {
33 ($t:ty) => {
34 impl BitStore for $t {
35 const BITS: u32 = Self::BITS;
36 const ONE: Self = 1;
37 const ZERO: Self = 0;
38
39 fn log2(self) -> u32 {
40 Self::ilog2(self)
41 }
42 }
43 };
44}
45
46impl_bitstore! {u32}
47impl_bitstore! {u64}
48impl_bitstore! {u128}