use super::*;
use crate::{
cursor::Cursor,
slice::BitSlice,
store::BitStore,
};
use core::{
marker::{
PhantomData,
Unpin,
},
mem,
pin::Pin,
};
impl<C, T> BitBox<C, T>
where C: Cursor, T: BitStore {
pub fn new(bits: &BitSlice<C, T>) -> Self {
Self::from_bitslice(bits)
}
pub fn pin(bits: &BitSlice<C, T>) -> Pin<Self>
where C: Unpin, T: Unpin {
Pin::new(Self::new(bits))
}
pub unsafe fn from_raw(raw: BitPtr<T>) -> Self {
Self {
_cursor: PhantomData,
pointer: raw,
}
}
pub fn into_raw(b: Self) -> BitPtr<T> {
let out = b.pointer;
mem::forget(b);
out
}
pub fn leak<'a>(self) -> &'a mut BitSlice<C, T> {
let out = self.bitptr();
mem::forget(self);
out.into_bitslice_mut()
}
}