#[cfg(feature = "alloc")]
use crate::mem::Boxed;
use crate::{list::Array, mem::Storage, misc::DataCollection};
mod impls;
mod methods;
pub struct BitArray<S: Storage, const BITLEN: usize, const BYTECAP: usize> {
array: Array<u8, S, BYTECAP>,
}
pub type BitArray8<S> = BitArray<S, 8, 1>;
pub type BitArray16<S> = BitArray<S, 16, 2>;
pub type BitArray32<S> = BitArray<S, 32, 4>;
pub type BitArray64<S> = BitArray<S, 64, 8>;
pub type BitArray128<S> = BitArray<S, 128, 16>;
pub type DirectBitArray<const BITLEN: usize, const BYTECAP: usize> = BitArray<(), BITLEN, BYTECAP>;
pub type DirectBitArray8 = BitArray<(), 8, 1>;
pub type DirectBitArray16 = BitArray<(), 16, 2>;
pub type DirectBitArray32 = BitArray<(), 32, 4>;
pub type DirectBitArray64 = BitArray<(), 64, 8>;
pub type DirectBitArray128 = BitArray<(), 128, 16>;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedBitArray<const BITLEN: usize, const BYTECAP: usize> =
BitArray<Boxed, BITLEN, BYTECAP>;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedBitArray8 = BitArray<Boxed, 8, 1>;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedBitArray16 = BitArray<Boxed, 16, 2>;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedBitArray32 = BitArray<Boxed, 32, 4>;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedBitArray64 = BitArray<Boxed, 64, 8>;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedBitArray128 = BitArray<Boxed, 128, 16>;
pub use all::*;
pub(crate) mod all {
#[doc(inline)]
#[cfg(feature = "alloc")]
pub use super::{
BoxedBitArray, BoxedBitArray128, BoxedBitArray16, BoxedBitArray32, BoxedBitArray64,
BoxedBitArray8,
};
#[doc(inline)]
pub use super::{
BitArray, DirectBitArray, DirectBitArray128, DirectBitArray16, DirectBitArray32,
DirectBitArray64, DirectBitArray8,
};
}
impl<S: Storage, const BITLEN: usize, const BYTECAP: usize> DataCollection
for BitArray<S, BITLEN, BYTECAP>
{
type Element = bool;
fn collection_is_empty(&self) -> Option<bool> {
None
}
fn collection_is_full(&self) -> Option<bool> {
None
}
fn collection_capacity(&self) -> usize {
BITLEN
}
fn collection_len(&self) -> usize {
BITLEN
}
}