pub mod bit_field_vec;
pub use bit_field_vec::*;
pub mod bit_vec;
pub use bit_vec::*;
pub use crate::bit_field_vec;
pub use crate::bit_vec;
macro_rules! test_unaligned {
($ty:ty, $bw:expr) => {{
let bits = <$ty>::BITS as usize;
$bw <= bits - 8 + 2 || $bw == bits - 8 + 4 || $bw == bits
}};
}
pub(crate) use test_unaligned;
macro_rules! ensure_unaligned {
($ty:ty, $bw:expr) => {
if !test_unaligned!($ty, $bw) {
let bits = <$ty>::BITS as usize;
return Err($crate::traits::UnalignedConversionError(format!(
"bit width {} does not satisfy the constraints for unaligned reads on word type {} (must be <= {}, or == {}, or == {})",
$bw, stringify!($ty), bits - 8 + 2, bits - 8 + 4, bits,
)));
}
};
}
pub(crate) use ensure_unaligned;
macro_rules! assert_unaligned {
($ty:ty, $bw:expr) => {
assert!(test_unaligned!($ty, $bw),
"bit width {} does not satisfy the constraints for unaligned reads on word type {} (must be <= {}, or == {}, or == {})",
$bw, stringify!($ty), <$ty>::BITS as usize - 8 + 2, <$ty>::BITS as usize - 8 + 4, <$ty>::BITS as usize,
);
};
}
pub(crate) use assert_unaligned;
macro_rules! debug_assert_unaligned {
($ty:ty, $bw:expr) => {
debug_assert!(test_unaligned!($ty, $bw),
"bit width {} does not satisfy the constraints for unaligned reads on word type {} (must be <= {}, or == {}, or == {})",
$bw, stringify!($ty), <$ty>::BITS as usize - 8 + 2, <$ty>::BITS as usize - 8 + 4, <$ty>::BITS as usize,
);
};
}
pub(crate) use debug_assert_unaligned;