use crate::{BumpScope, align_pos, settings::BumpAllocatorSettings};
pub(crate) struct BumpAlignGuard<'b, 'a, A, S>
where
S: BumpAllocatorSettings,
{
pub(crate) scope: &'b mut BumpScope<'a, A, S>,
}
impl<A, S> Drop for BumpAlignGuard<'_, '_, A, S>
where
S: BumpAllocatorSettings,
{
#[inline(always)]
fn drop(&mut self) {
if let Some(chunk) = self.scope.raw.chunk.get().as_non_dummy() {
let pos = chunk.pos().addr().get();
let addr = align_pos(S::UP, S::MIN_ALIGN, pos);
unsafe { chunk.set_pos_addr(addr) };
}
}
}
impl<'b, 'a, A, S> BumpAlignGuard<'b, 'a, A, S>
where
S: BumpAllocatorSettings,
{
#[inline(always)]
pub(crate) fn new(scope: &'b mut BumpScope<'a, A, S>) -> Self {
Self { scope }
}
}