use crate::heap_strategy_provider::LenStrategy;
use crate::heap_strategy_provider::StrategyProvider;
use crate::lenty_provide::ProvideLenTy;
#[repr(transparent)]
pub struct LenField<LenTy: const ProvideLenTy, const HEAP: bool> {
lenty: LenTy,
}
impl<LenTy: const ProvideLenTy, const HEAP: bool> LenField<LenTy, HEAP>
where
(): const StrategyProvider<LenTy, HEAP>,
{
#[inline]
pub const fn new() -> Self {
LenField {
lenty: LenTy::ZERO,
}
}
#[inline]
pub const fn get_len(&self) -> LenTy {
<() as StrategyProvider<LenTy, HEAP>>::Strategy::get_len(self.lenty)
}
#[inline]
pub const unsafe fn set_len(&mut self, new_len: LenTy) {
<() as StrategyProvider<LenTy, HEAP>>::Strategy::set_len(
&mut self.lenty,
new_len,
);
}
#[inline]
pub const fn get_is_heap(&self) -> bool {
<() as StrategyProvider<LenTy, HEAP>>::Strategy::get_is_heap(self.lenty)
}
#[inline]
pub const unsafe fn set_is_heap(&mut self, is_heap: bool) {
<() as StrategyProvider<LenTy, HEAP>>::Strategy::set_is_heap(
&mut self.lenty,
is_heap,
);
}
}